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 cl[9],res[20],min=100,prin[20]; int count[10]={0}; int move[10][9]={{0},{1,1,0,1,1},{1,1,1},{0,1,1,0,1,1},{1,0,0,1,0,0,1},{0,1,0,1,1,1,0,1}, {0,0,1,0,0,1,0,0,1},{0,0,0,1,1,0,1,1},{0,0,0,0,0,0,1,1,1},{0,0,0,0,1,1,0,1,1}}; void solve(int t,int op); int main() { int i; for(i=0;i<9;++i) { cin>>cl[i]; } for(i=1;i<10;++i) { for(i=0;i<10;++i) count[i]=0; solve(0,i); } for(i=0;i<min;++i) cout<<prin[i]<<' '; return 0; } void solve(int t,int op) { int i,temp[9]; bool flag; if(t>30) return; for(i=0;i<9;++i) temp[i]=cl[i]; count[op]++; res[t]=op; for(i=0;i<9;++i) { cl[i]=(cl[i]+move[op][i])%4; } for(flag=true,i=0;i<9;++i) { if(cl[i]!=0) { flag=false; break; } } if(flag && t+1<min) { for(i=0;i<=t;++i) prin[i]=res[i]; min=t+1; count[op]--; for(i=0;i<9;++i) cl[i]=temp[i]; }else { for(i=op;i<10;++i) { if(count[i]<3) solve(t+1,i); } } count[op]--; for(i=0;i<9;++i) cl[i]=temp[i]; } Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator