fork(3) download
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3.  
  4. const int mod = 1e9 + 7;
  5. const int n = 1e6;
  6. int a[n];
  7.  
  8. int main() {
  9. for(int i = 0; i < n; i++) {
  10. a[i] = rand() % mod;
  11. }
  12. int s = 0;
  13. for(int rep = 0; rep < 50123; ++rep) {
  14. a[rand()%n] = rand() % mod;
  15. int start = rand() % n;
  16. s += a[start];
  17. for(int j = start; j < min(n, start + 9000); j++) {
  18. // s = (s + a[j] < mod ? s+a[j] : s+a[j]-mod);
  19. s = (s + a[j]) % mod;
  20. }
  21. }
  22. cout << s << endl;
  23. }
Success #stdin #stdout 1.46s 7600KB
stdin
Standard input is empty
stdout
979631356