fork download
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3.  
  4. bool isPrime(int x) {
  5. if (x < 2) return false;
  6. for (int i = 2; i * i <= x; i++)
  7. if (x % i == 0) return false;
  8. return true;
  9. }
  10.  
  11. int main() {
  12. ios::sync_with_stdio(false);
  13. cin.tie(nullptr);
  14. string n;
  15. long long Y;
  16. cin >> n >> Y;
  17. long long S = 0;
  18. for (char c : n) S += c - '0';
  19. int R;
  20. if (n.size() == 1) R = n[0] - '0';
  21. else R = (n[1]-'0') * 10 + (n[0]-'0');
  22. long long A = 0;
  23. long long tempY = Y;
  24. while (tempY) {
  25. A += tempY % 10;
  26. tempY /= 10;
  27. }
  28. double x0 = S + (A % 10);
  29. double y0 = (R + A) % 100;
  30. double x = 21.268443;
  31. double y = 105.204557;
  32. double d = sqrt((x0 - x)*(x0 - x) + (y0 - y)*(y0 - y));
  33. int K = (int) d;
  34. if (isPrime(K)) cout << "YES";
  35. else cout << "NO";
  36. }
  37.  
Success #stdin #stdout 0s 5316KB
stdin
Standard input is empty
stdout
NO