Advertisement
raihan02

Untitled

Nov 8th, 2016
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.43 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2. typedef long long int ll;
  3. using namespace std;
  4. int main()
  5. {
  6. ll n;
  7. while(cin >> n and n)
  8. {
  9. ll res = 0, p = 0 ,a;
  10. ll k = 1;
  11. for(int i = 1; i <= n; i++)
  12. {
  13. if(k >= n)
  14. break;
  15. a = n / k , p = n / a;
  16. res += a * ((k + p) * (p -k + 1)/ 2);
  17. k = p + 1;
  18.  
  19. }
  20.  
  21. cout<< res - 1<< endl;
  22. }
  23.  
  24.  
  25. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement