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 |
为什么会wa啊。。好伤自尊。。麻烦各位大侠帮忙看看错在哪?#include<iostream> using namespace std; int main() { int result[10],input[10],list[10]; int minT=27,minI,times,tmp; const int move[10][10]={ {0,0,0,0,0,0,0,0,0,0}, {0,1,1,0,1,1,0,0,0,0}, {0,1,1,1,0,0,0,0,0,0}, {0,0,1,1,0,1,1,0,0,0}, {0,1,0,0,1,0,0,1,0,0}, {0,0,1,0,1,1,1,0,1,0}, {0,0,0,1,0,0,1,0,0,1}, {0,0,0,0,1,1,0,1,1,0}, {0,0,0,0,0,0,0,1,1,1}, {0,0,0,0,0,1,1,0,1,1} }; for(int m=1;m<10;m++){ cin>>tmp; input[m]=(4-tmp)%4; } for(int i=0;i<=262143;i++){ tmp=i; memset(result,0,sizeof(int)*10); times=0; for(int j=1;j<=9;j++){ list[j]=tmp%4; tmp=tmp/4; for (int k=1;k<=9;k++) { result[k]+=move[j][k]*list[j]; } } for (int m=1;m<=9;m++) { result[m]=result[m]%4; } int idx; for(idx=1;idx<10;idx++){ if(result[idx]!=input[idx])break; } if(idx==10){ for(int n=1;n<=9;n++) times+=list[n]; if(times<minT){ minT=times; minI=i; } } } for(int q=1;q<=9;q++){ list[q]=minI%4; minI=minI/4; while (list[q]>0) { cout<<q; if (q!=9 || list[q]!=1) { cout<<" "; } list[q]--; } } cout<<endl; return 0; } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator