fork(1) download
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3. long long int flooring(int);
  4. long long int a[3000000]={0};
  5. int main() {
  6. // your code goes here
  7. int t;
  8. cin>>t;
  9. while(t--)
  10. {
  11. int n;
  12. cin>>n;
  13. cout<<flooring(n)<<"\n";
  14. }
  15. return 0;
  16. }
  17. long long int flooring(int x)
  18. {
  19.  
  20. if(a[x]!=0)
  21. return a[x];
  22. else
  23. a[x]=floor((double)(x/2))+flooring(x-1);
  24. return a[x];
  25. }
Success #stdin #stdout 0s 26584KB
stdin
5
1
2
3
4
5
stdout
3078082647
3078082648
3078082649
3078082651
3078082653