Saleh127

Light oj(LO) 1098

Apr 17th, 2021
191
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.57 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 csod(ll n)
  6. {
  7. ll i,j,k,l,ans=0;
  8. for(i=2; i<=sqrt(n); i++)
  9. {
  10. j=n/i;
  11. ans+=((j+i)*(j-i+1))/2;
  12. ans+=(i*(j-i));
  13. }
  14. return ans;
  15. }
  16.  
  17. int main()
  18. {
  19. ios_base::sync_with_stdio(0);
  20. cin.tie(0);
  21. cout.tie(0);
  22.  
  23. ll a;
  24.  
  25. test
  26. {
  27. cin>>a;
  28. cout<<"Case "<<cs<<": "<<csod(a)<<endl;
  29. }
  30.  
  31. return 0;
  32. }
  33. ///if 1 and n consider then answer is ans+=(n*(n+1))/2 + n-1;
  34.  
Advertisement
Add Comment
Please, Sign In to add comment