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 |
Re:给个数据把...WA的没想法了!In Reply To:给个数据把...WA的没想法了! Posted by:Kinkoyo at 2005-10-20 19:08:44 更新版本!可是还是WA #include<iostream> #include<fstream> using namespace std; int main(){ //ifstream cin("a.in"); __int64 d,n,sum,j,k; int i; while(cin>>d>>n){ if(d==0&&n==0) break; 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); } printf("%I64d\n",sum);continue; } if(d==n){ sum=1; while(n>=100000){ i=i+1; if(d%(i)==0){ j=d/(i); } else { j=d/(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){ if(d%n==0){ sum+=d/n; } else { sum+=d/n+1; } while(n>=100000){ i=i+1; if(d%(i)==0){ j=d/(i); } else { j=d/(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(d%(i)==0){ j=d/(i); } else { j=d/(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