Online Judge | Problem Set | Authors | Online Contests | User | ||||||
---|---|---|---|---|---|---|---|---|---|---|
Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest |
给个数据把...WA的没想法了!#include<iostream> #include<fstream> using namespace std; int main(){ //ifstream cin("a.in"); //ofstream cout("b.out"); __int64 d,n,m,sum,j,k; int i; while(cin>>d>>n){ if(d==0&&n==0) break; m=d;sum=0;i=1; if(n<100000){ for(j=1;j<=n;j++){ if(d%j==0){ sum+=d/j; } else { sum+=d/j; sum+=1; } } printf("%I64d\n",sum);continue; } if(d==n){ sum=1; while(n>=100000){ i=i+1; if(m%(i)==0){ j=m/(i); } else { j=m/(i)+1; } k=n-1;n=j; sum+=i*(k-n+1); } for(j=1;j<n;j++){ if(d%j==0){ sum+=d/j; } else { sum+=d/j; sum+=1; } } } else if(d>n){ while(n>=100000){ i=i+1; if(m%(i)==0){ j=m/(i); } else { j=m/(i)+1; } k=n-1;n=j; sum+=i*(k-n+1); } for(j=1;j<=n;j++){ if(d%j==0){ sum+=d/j; } else { sum+=d/j; sum+=1; } } } else { sum+=n-d+1;n=d-1; while(n>=100000){ i=i+1; if(m%(i)==0){ j=m/(i); } else { j=m/(i)+1; } k=n-1;n=j; sum+=i*(k-n+1); } for(j=1;j<=n;j++){ if(d%j==0){ sum+=d/j; } else { sum+=d/j; sum+=1; } } } printf("%I64d\n",sum); } } Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator