Saleh127

UVA 11554

Sep 12th, 2020
193
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.65 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3. #define ll long long
  4. #define test int t; cin>>t; for(int cs=1;cs<=t;cs++)
  5. ll tri[1000005],cur[1000005];
  6. int main()
  7. {
  8. ios_base::sync_with_stdio(0);
  9. cin.tie(0);
  10. cout.tie(0);
  11.  
  12. ll i,j,k,l,a,c,d=0;
  13.  
  14. ///tri[3]=cur[3]=0;
  15. for(i=4; i<=1000003; i++)
  16. {
  17. if(i%2==0)
  18. {
  19. d++;
  20. cur[i]=cur[i-1]+d;
  21. tri[i]=tri[i-1]+cur[i];
  22. }
  23. else
  24. {
  25. cur[i]=cur[i-1]+d;
  26. tri[i]=tri[i-1]+cur[i];
  27. }
  28. }
  29.  
  30. test
  31. {
  32. cin>>a;
  33. cout<<tri[a]<<endl;
  34. }
  35.  
  36. return 0;
  37. }
  38.  
  39.  
Advertisement
Add Comment
Please, Sign In to add comment