Advertisement
momo2345

sum of divisors

Oct 9th, 2020
103
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.72 KB | None | 0 0
  1. #include<bits/stdc++.h>
  2. using namespace std;
  3. typedef long long ll;
  4. #include <ext/pb_ds/assoc_container.hpp>
  5. using namespace __gnu_pbds;
  6. typedef tree<ll,null_type,less_equal<ll>,rb_tree_tag,tree_order_statistics_node_update>ordered_set;
  7. #define suni ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
  8. #define endl "\n"
  9. #define mn int main()
  10. #define frac() cout.unsetf(ios::floatfield);cout.precision(6);cout.setf(ios::fixed,ios::floatfield);
  11. const int mx=1e7+123;
  12. int a[mx];
  13. mn
  14. {
  15.      suni;
  16.      int n;
  17.      cin>>n;
  18.      for(int i=1;i<=n;i++)
  19.      {
  20.          for(int j=i;j<=n;j+=i)
  21.             a[j]++;
  22.      }
  23.      ll ans=0;
  24.      for(int i=1;i<=n;i++)
  25.         ans+=( 1LL*i*a[i]);
  26.      cout<<ans<<endl;
  27.     }
  28.  
  29.  
  30.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement