fork download
  1. #include<bits/stdc++.h>
  2. using namespace std;
  3. #define FR0(i,N) for(i=0;i<(N);i++)
  4. #define FR1(i,N) for(i=1;i<=(N);i++)
  5. #define FRN(i,k,N) for(i=k;i<(N);i++)
  6. #define pf printf
  7. #define db double
  8. #define max3(a,b,c) max(max(a,b),c)
  9. #define min3(a,b,c) min(min(a,b),c)
  10. #define sci(n) scanf("%d",&n)
  11. #define scl(n) scanf("%lld",&n)
  12. #define scf(n) scanf("%f",&n)
  13. #define scd(n) scanf("%lf",&n)
  14. #define scs(s) scanf("%s",&s)
  15. #define scll(n) scanf("%%I64d",&n)
  16. #define PI acos(-1.0)
  17. #define LL long long
  18. #define MX 1000005
  19. #define MOD 1000000007
  20. typedef long long int ll;
  21. bool status[1100002];
  22. int gcd(int a,int b)
  23. {
  24. if(b==0) return a;
  25. else return gcd(b,a%b);
  26. }
  27. int main()
  28. {
  29. int n,t=1;
  30. char s1[30],s2[30];//No string will have more than 30 characters.According to problem description;
  31. scanf("%d",&n);
  32. while(n--)
  33. {
  34. scanf("%s%s",&s1,&s2);
  35. //cout<<s1<<" "<<s2<<endl;
  36. int decimal_s1=0;
  37. int n=0;
  38. for(int i=strlen(s1)-1;i>=0;i--)//Covert first string to decimal;
  39. {
  40. decimal_s1+=(s1[i]-48)*pow(2,n++);
  41. }
  42. int decimal_s2=0;
  43. int k=0;
  44. for(int i=strlen(s2)-1;i>=0;i--)//convert second string to decimal;
  45. {
  46. decimal_s2+=(s2[i]-48)*pow(2,k++);
  47. }
  48. int res=gcd(decimal_s1,decimal_s2);//find gcd two decimal;
  49. //cout<<"decimal_s1 = "<<decimal_s1<<" decimal_s2 = "<<decimal_s2<<endl;
  50. //cout<<"res = "<<res<<endl;
  51. if(res==1)//if gcd is 1;
  52. {
  53. printf("Pair #%d: Love is not all you need!\n",t++);
  54. }
  55. else
  56. {
  57. printf("Pair #%d: All you need is love!\n",t++);
  58. }
  59. }
  60. }
  61.  
Success #stdin #stdout 0s 4536KB
stdin
5
11011
11000
11011
11001
111111
100
1000000000
110
1010
100
stdout
Pair #1: All you need is love!
Pair #2: Love is not all you need!
Pair #3: Love is not all you need!
Pair #4: All you need is love!
Pair #5: All you need is love!