Advertisement
Imran2544

[UVa 10193] All You Need is Love

Nov 4th, 2018
173
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.62 KB | None | 0 0
  1. #include<bits/stdc++.h>
  2. using namespace std;
  3.  
  4. int bintodec(string s)
  5. {
  6.     int l=s.length(), base=1, dec=0;
  7.     for (int i=l-1; i>=0; i--) {
  8.         if (s[i]=='1')
  9.             dec+=base;
  10.         base*=2;
  11.     }
  12.     return dec;
  13. }
  14.  
  15. int main()
  16. {
  17.     int n, t=1;
  18.     scanf("%d", &n);
  19.     while (n--) {
  20.         string s1, s2;
  21.         cin>>s1;
  22.         cin>>s2;
  23.         int x=bintodec(s1);
  24.         int y=bintodec(s2);
  25.         if (__gcd(x,y)==1)
  26.             printf("Pair #%d: Love is not all you need!\n", t++);
  27.         else
  28.             printf("Pair #%d: All you need is love!\n", t++);
  29.     }
  30.     return 0;
  31. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement