fork(3) download
  1. #include<bits/stdc++.h>
  2. using namespace std;
  3.  
  4. typedef long long Int;
  5. Int sqr(int x) { return (Int) x*x; }
  6.  
  7. int main()
  8. {
  9. int n;
  10. cin >> n;
  11. Int ans = 0;
  12. for (int side = 1; side <= n; side++) {
  13. int first = (side+2)/2 ; //2*first-1 >= x
  14. int last = n-side+1;
  15. if (first > last) break;
  16. Int cnt = sqr(last) - sqr(first-1) - (Int) (side-1) * (last-first+1);
  17. ans += cnt;
  18. }
  19. cout << ans;
  20. }
  21.  
Success #stdin #stdout 0.01s 5664KB
stdin
4
stdout
23