-
Notifications
You must be signed in to change notification settings - Fork 69
/
Copy path10193.cpp
51 lines (41 loc) · 781 Bytes
/
10193.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
#include <iostream>
#include <string>
#include <cmath>
#include <algorithm>
using namespace std;
int bin2dec(const string &s) {
int counter = 0;
int result = 0;
for (int i = s.size() - 1; i >= 0; i--) {
if (s[i] == '1') {
result += (int)pow(2, counter);
}
counter++;
}
return result;
}
int gcd(int a, int b) {
while (b) {
a %= b;
swap(a, b);
}
return a;
}
int main(void) {
int n, a, b;
string input;
cin >> n;
for (int i = 0; i < n; i++) {
cin >> input;
a = bin2dec(input);
cin >> input;
b = bin2dec(input);
cout << "Pair #" << i+1 << ": ";
if (gcd(a, b) > 1) {
cout << "All you need is love!" << endl;
} else {
cout << "Love is not all you need!" << endl;
}
}
return 0;
}