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> #include<cmath> #include<bitset> using namespace std; int main(void) { int aa; while(cin>>aa) { int m; int n; int i; int cnt=0; bitset<1000001> b; b.set(0); for(m=1;m<(int)sqrt((double)aa)+1;m++) for(n=1;n<m;n++) if((m*m+n*n)>aa)break; else if( (m%2==0&&n%2==0)||(m%2&&n%2)||(m%n==0&&n!=1) ) continue; else { cnt++; int k=m*m+n*n; for(i=1;i<=aa/k;i++) { b[i*k]=1; b[i*2*m*n]=1; b[i*(m*m-n*n)]=1; } } cout<<cnt<<" "; cnt=0; for(i=1;i<=aa;i++) if(b[i]==0)cnt++; else b[i]=0; cout<<cnt; } return 0; } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator