Salvens

Untitled

Oct 31st, 2023 (edited)
521
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.90 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2.  
  3. //#include <ext/pb_ds/assoc_container.hpp>
  4. //using namespace __gnu_pbds;
  5.  
  6. using namespace std;
  7.  
  8. #define int long long
  9. #define IOS ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
  10.  
  11. const long long INF = 1e18 + 7;
  12. const double EPS = 1e-6;
  13. const int MOD = 1e9 + 7;
  14. const int MAXN = 2e5 + 100;
  15.  
  16. int n = 1046527;
  17.  
  18. bool is_prime(int a) {
  19.     if (a == 1) {
  20.         return false;
  21.     }
  22.     for (int i = 2; i * i <= a; ++i) {
  23.         if (a % i == 0) {
  24.             return false;
  25.         }
  26.     }
  27.     return true;
  28. }
  29.  
  30. inline void solve() {
  31.     int ans = 0;
  32.     for (int i = 0; i < n; ++i) {
  33.         if (n - 2 * i > 0 && is_prime(n - 2 * i)) {
  34.             ans = max(ans, n - 2 * i);
  35.         }
  36.     }
  37.     cout << ans << '\n';
  38. }
  39.  
  40.  
  41. int32_t main() {
  42.     IOS;
  43.  
  44.     int tt = 1;
  45. //    cin >> tt;
  46.     while (tt --> 0) {
  47.         solve();
  48.     }
  49.     return 0;
  50. }
  51.  
  52.  
Advertisement
Add Comment
Please, Sign In to add comment