Advertisement
Saleh127

UVA 11526

Mar 12th, 2021
110
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.57 KB | None | 0 0
  1.  
  2. ///https://acmproblemsolution.blogspot.com/2013/11/algorithm-of-11526-hn.html
  3. #include <bits/stdc++.h>
  4. using namespace std;
  5. #define ll long long
  6. #define test int t; cin>>t; for(int cs=1;cs<=t;cs++)
  7. int main()
  8. {
  9. ios_base::sync_with_stdio(0);
  10. cin.tie(0);cout.tie(0);
  11.  
  12. test
  13. {
  14.  
  15. ll a,b=0,i,j,k;
  16. cin>>a;
  17.  
  18. for(i=1;i<=a;i++)
  19. {
  20. k=(a/i)-(a/(i+1));
  21. if(k<=0) break;
  22.  
  23. b+=(k*i);
  24. }
  25.  
  26. for(i=a/(i+1);i>=1;i--)
  27. {
  28. b+=(a/i);
  29. }
  30.  
  31. cout<<b<<endl;
  32. }
  33.  
  34.  
  35. return 0;
  36. }
  37.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement