Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<bits/stdc++.h>
- using namespace std;
- const int mx=1e7+123;
- #define optimize() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
- long long int cnt[mx];
- int main()
- {
- //This coding complexity is n ln n but their square root loop will take n sqrt(n);
- optimize();
- int n;
- cin>>n;
- for(int i=1;i<=n;i++)
- {
- for(int j=i;j<=n;j+=i)
- {
- cnt[j]++;
- }
- }
- long long int ans=0;
- for(int i=1;i<=n;i++)
- {
- ans+=(i*cnt[i]);
- }
- cout<<ans;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement