fork(2) download
  1. #include <bits/stdc++.h>
  2. #define ll long long int
  3. #define debug(...) fprintf(stderr, __VA_ARGS__), fflush(stderr)
  4. #define time__(d) \
  5.   for ( \
  6.   auto blockTime = make_pair(chrono::high_resolution_clock::now(), true); \
  7.   blockTime.second; \
  8.   debug("%s: %d ms\n", d, (int)chrono::duration_cast<chrono::milliseconds>(chrono::high_resolution_clock::now() - blockTime.first).count()), blockTime.second = false \
  9.   )
  10. using namespace std;
  11.  
  12. ll sum_till_a(int a){
  13. ll res=0;
  14. while(a){
  15. res+=a;
  16. a--;
  17. }
  18. return res;
  19. }
  20.  
  21. int main(){
  22. ll a , res=0;
  23. cin>>a;
  24.  
  25. time__("Solve Time"){
  26. res = sum_till_a(a);
  27. }
  28.  
  29. cout<<res;
  30. return 0;
  31. }
Success #stdin #stdout #stderr 0.03s 4904KB
stdin
99999999
stdout
4999999950000000
stderr
Solve Time: 26 ms