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 |
为什么上了一定数量就变成负的了?#include<iostream> using namespace std; int eun[1000005]={0}; int ans[1000005]={0}; int eular(int m) { int ans=m; int n=m; for(int i=2;i*i<=m;i++) { if(n%i==0) { ans=ans-ans/i; while(n%i==0) n/=i; } } if(n!=1) ans=ans-ans/n; return ans; } int main() { int n,i,sum; ans[1]=0; for(i=2;i<=100000;i++) { eun[i]=eular(i); ans[i]=ans[i-1]+eun[i]; } while(scanf("%d",&n)&&n) { if(n==0) { break; } printf("%d\n",ans[n]); } return 0; } Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator