#include<bits/stdc++.h> using namespace std; #define LL long long #define DB double #define pb push_back #define pii pair<int,int> #define mpt make_pair #define fr first #define sc second #define M 500020//Size #define INF 1000000000 #define INFLL 1000000000000000000 inline int read(){ int nm=0,fh=1; char c=getchar(); for(;!isdigit(c);c=getchar()) if(c=='-') fh=-1; for(;isdigit(c);c=getchar()) nm=nm*10+c-'0'; return nm*fh; } #define mod 1000000007//Attention inline int add(int x,int y){return (x+y>=mod)?(x+y-mod):(x+y);} inline int mns(int x,int y){return (x-y<0)?(x-y+mod):(x-y);} inline int mul(LL x,LL y){return x*y%mod;} inline void upd(int &x,int y){x=(x+y>=mod)?(x+y-mod):(x+y);} inline void dec(int &x,int y){x=(x-y<0)?(x-y+mod):(x-y);} inline int qpow(int x,LL sq){int res=1;for(;sq;sq>>=1,x=mul(x,x))if(sq&1)res=mul(res,x);return res;} class Solution { public: long long Sum(int n) { // write code here LL ans=0ll,res=0ll; for(LL l=1,r;l<=n;l=r+1){ r=min(n/(n/l),(LL)n); ans+=(LL)(r-l+1)*(n/l); } for(LL i=1;i*i<=n;i++) if(n%i==0){ res++; if((i*i)^n) res++; } ans+=(LL)n-res; return ans; } }t;
全部评论
(11) 回帖