fork download
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3. #define ll long long
  4. #define endl "\n"
  5. vector<ll> primes;
  6. vector<ll> is_prime(1000001);
  7. ll N=0;
  8. ll ans2;
  9. ll x;
  10. void solve()
  11. {
  12. ll k;
  13. x = 0;
  14. k = 999983;
  15. ll ans=0, mn=1e9;
  16. for (int i=0;i<N;i++)
  17. {
  18. ans+=k*primes[i];
  19. if (k%primes[i]==0)
  20. x=i;
  21. if (primes[i]==is_prime[k])
  22. break;
  23. }
  24. // for (int i=0;i<N;i++)
  25. // {
  26. // ans+=k*primes[i];
  27. // if (!(k%primes[i]))
  28. // break;
  29. // }
  30. x+=ans;
  31. ans2 += ans % 10000;
  32. }
  33. int main()
  34. {
  35. ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  36. ll t;
  37. int n=1e6;
  38. for (int i=0;i<n;i++)
  39. is_prime[i]=i;
  40. is_prime[0] = is_prime[1] = -1;
  41. for (ll i = 2; i * i <= n; i++) {
  42. if (is_prime[i]) {
  43. for (ll j = i * i; j <= n; j += i)
  44. is_prime[j] = min(i, is_prime[j]);
  45. }
  46. }
  47. for (int i=2;i<=n;i++)
  48. if (is_prime[i]==i)
  49. primes.push_back(i),N++;
  50. t = 10000;
  51. while(t--)
  52. {
  53. solve();
  54. }
  55. cout << ans2 << '\n';
  56. return 0;
  57. }
Time limit exceeded #stdin #stdout 5s 11924KB
stdin
Standard input is empty
stdout
Standard output is empty