ITSA 第三十四屆第五題題目
團隊:Voir-dire
程式碼:
#include <iostream>
#include <string>
using namespace std;
int main()
{
cout.setf(ios::fixed, ios::floatfield);
cout.precision(2);
int n, i = 0;
for(cin >> n; i < n; ++i)
{
int tp = 0, fp = 0, fn = 0;
string s1, s2;
cin >> s1 >> s2;
for(int j = 0; s1[j]; ++j)
{
if(s1[j] == '1' && s1[j] == s2[j]) ++tp;
if(s1[j] == '1' && s1[j] != s2[j]) ++fp;
if(s1[j] == '0' && s1[j] != s2[j]) ++fn;
}
double p1 = (double)tp / (tp + fp);
double p2 = (double)tp / (tp + fn);
if(p2 > 1) cout << "0.00 ";
else cout << p2 << ' ';
if(p1 > 1) cout << "0.00 ";
else cout << p1 << endl;
}
return 0;
}