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; inline void ss(int n); inline void jia(int m); int b[2000],e,q; int main() { b[0]=2;b[1]=3; int a[10005],i; for( i=0;i<10005;i++) {cin>>a[i]; if(a[i]==0) break;} for(int j=0;j<i;j++) { if(a[j]==2||a[j]==3) cout<<1<<endl; else { jia(a[j]); }}} inline void ss(int n) { e=2; for(int j=4;j<=n;j++) { for(int k=2;k<=j/2;k++) { if(j%k==0) break; if(k==(j/2)) { b[e]=j; e++; }}}} inline void jia(int m) { ss(m); int max; q=0; for(int x=0;x<e-1;x++) { max=b[x]; for(int y=x+1;y<e-1;y++) { max+=b[y]; if(max==m) q++; else continue;}} if(b[e-1]==m) cout<<q+1<<endl; else cout<<q<<endl; } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator