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 |
Magic of David Copperfield这道题的Special Judged 似乎不够全面,我的检验了还老wrong anwser,我的代码如下#include<iostream.h> void main() { long num; cin>>num; bool rec[200][200],nolast=true; long row=0,i,j,count,line=1; for(i=1;i<=num;i++) { rec[num][i]=true; rec[num-1][i]=true; } for(i=1,count=1;;i+=2,count++) { if(count%2&&nolast) row++; cout<<i; if(row==num-1) { nolast=false; if(!rec[num-1][line]&&!rec[num][line]) line++; if((num-1+line-count)%2) { if(rec[num-1][line]) { rec[num-1][line]=false; cout<<" "<<(num-2)*num+line; } } else if(rec[num][line]) { rec[num][line]=false; cout<<" "<<(num-1)*num+line; } if(line==num&&(!rec[num-1][num]||!rec[num][num])) break; } else for(j=1;j<=num;j++) if((j+row-count)%2) cout<<" "<<(row-1)*num+j; cout<<endl; } cout<<endl; } Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator