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. void solve()
  10. {
  11. ll k;
  12. ll x = 0;
  13. k = 999983;
  14. ll ans=0, mn=1e9;
  15. for (int i=0;i<N;i++)
  16. {
  17. ans+=k*primes[i];
  18. if (k%primes[i]==0)
  19. x=i;
  20. if (primes[i]==is_prime[k])
  21. break;
  22. }
  23. // for (int i=0;i<N;i++)
  24. // {
  25. // ans+=k*primes[i];
  26. // if (!(k%primes[i]))
  27. // break;
  28. // }
  29. x+=ans;
  30. ans2 += ans % 10000;
  31. }
  32. int main()
  33. {
  34. ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  35. ll t;
  36. int n=1e6;
  37. for (int i=0;i<n;i++)
  38. is_prime[i]=i;
  39. is_prime[0] = is_prime[1] = -1;
  40. for (ll i = 2; i * i <= n; i++) {
  41. if (is_prime[i]) {
  42. for (ll j = i * i; j <= n; j += i)
  43. is_prime[j] = min(i, is_prime[j]);
  44. }
  45. }
  46. for (int i=2;i<=n;i++)
  47. if (is_prime[i]==i)
  48. primes.push_back(i),N++;
  49. t = 10000;
  50. while(t--)
  51. {
  52. solve();
  53. }
  54. cout << ans2 << '\n';
  55. return 0;
  56. }
Success #stdin #stdout 0.54s 12028KB
stdin
Standard input is empty
stdout
56090000