|
|
back to boardWhat is wrong??? It is easy problem but I still have a WA. Please help. #include <iostream.h> #define N 10001 #define M 50 short a[N]; int main(void) {short i,j,n,m,k[M],temp,p; cin>>n>>m; temp=N; for(j=0;j<m;j++) {cin>>k[j]; if(k[j]<temp) temp=k[j];} a[temp]=1; for(i=temp+1;i<=n;i++) { p=0; for(j=0;j<m;j++) { temp=i-k[j]; if(!temp)p=1; else if(temp>0&&a[temp]) { p=1; if(a[temp]==1){a[i]=2;break;} } } if(p&&!a[i]) a[i]=1; } cout<<(3-a[n])<<endl; return 0;} |
|
|