Number of Containers [ZOJ 3126]
http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemId=3216
View Code
//复杂度O(sqrt(N)),蛮有意思的 const int MM = 11111; typedef long long int64; int64 N; void solve() { int64 i,j,k,sum=0,tmp; scanf("%lld",&N); for(i=1;(i*i)<=N;i++) { tmp=N/i; sum=sum+i*(N/i-N/(i+1)); if(tmp!=i) sum=sum+tmp*(N/tmp-N/(tmp+1)); } printf("%lld\n",sum-N); }