fork download
  1. #pragma GCC optimize("Ofast")
  2. #pragma GCC target("avx")
  3. #include <bits/stdc++.h>
  4. const int mod = (int)1e9+7;
  5. int add(int a, int b) { return (a += b) >= mod ? a -= mod : a; }
  6. int mul(int a, int b) { return int(1LL * a * b % mod); }
  7. int pow(int a, int n) {
  8. if (n == 0) return 1;
  9. if (a <= 1) return a;
  10. int r(1);
  11. while (n) {
  12. if (n % 2) r = mul(a,r);
  13. a = mul(a,a);
  14. n >>= 1;
  15. }
  16. return r;
  17. }
  18. int main() {
  19. int s = 0;
  20. std::cout << "{" << s;
  21. for (int n = 1; n <= (int)1e7; n++) {
  22. int term = pow(n, mod-2);
  23. term = mul(term,term);
  24. s = add(s, term);
  25. if (n % (int)1e6 == 0) {
  26. std::cout << ',' << s;
  27. }
  28. }
  29. std::cout << "}";
  30. return 0;
  31. }
Success #stdin #stdout 1.34s 4452KB
stdin
Standard input is empty
stdout
{0,691281592,513558697,301428948,825737147,753460309,655962325,947635491,307001071,900886440,139907876}