fork download
  1. // AVADAKEDAVRA !!!!!
  2. #include <bits/stdc++.h>
  3. using namespace std;
  4. typedef long long int ll;
  5. typedef vector<int> vi;
  6. typedef pair<int,int> pii;
  7. double eps = 1e-9;
  8.  
  9. int gcd(int a,int b)
  10. {
  11. if(a<b)return gcd(b,a);
  12. if(b==0)return a;
  13. return gcd(b,a%b);
  14. }
  15. int issqr(int x)
  16. {
  17. int w = sqrt(x);
  18. if(w*w==x)return w;
  19. w++;
  20. if(w*w==x)return w;
  21. return 0;
  22. }
  23. class KnightOfIntegerland {
  24. public:
  25. string able(int, int, int);
  26. };
  27. vector<pii > sums;
  28. string KnightOfIntegerland::able(int d, int x, int y) {
  29. if(x<0)x=-x;
  30. if(y<0)y=-y;
  31. if( x == 0 && y == 0)return "YES";
  32. for(int i=0;i*i<=d;i++)
  33. {
  34. int w = d-i*i;
  35. if(issqr(w))
  36. {
  37. sums.push_back(pii(i,issqr(w)));
  38. }
  39. }
  40. vi alsteps,sparity;
  41. for(int i=0;i<sums.size();i++)
  42. {
  43. int x = sums[i].first, y = sums[i].second;
  44. int g = gcd(x,y);
  45. x/=g;y/=g;
  46. if( (y-x)& 1)
  47. {
  48. alsteps.push_back(g);
  49. }
  50. else sparity.push_back(g);
  51. }
  52. int a = 0;
  53. for(int i=0;i<alsteps.size();i++)
  54. a = gcd(a,alsteps[i]);
  55. for(int i=0;i<sparity.size();i++)
  56. a = gcd(a,2*sparity[i]);
  57. int b = 0;
  58. for(int i=0;i<sparity.size();i++)
  59. {
  60. b = gcd(b, sparity[i]);
  61. }
  62. if(a==0)return "NO";
  63. if( (x-y)%a != 0)return "NO";
  64. for(int k=0;k<a;k++)
  65. {
  66. if( (x-b*k)%a==0)return "YES";
  67. }
  68. return "NO";
  69. }
  70.  
  71. <%:testing-code%>
  72. //Powered by [KawigiEdit] 2.0!
  73.  
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
1 1 1 
compilation info
prog.cpp:71:1: error: expected unqualified-id before '<%' token
 <%:testing-code%>
 ^
stdout
Standard output is empty