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 |
Re:PE????求大牛帮忙(附代码)In Reply To:PE????求大牛帮忙(附代码) Posted by:fortunato at 2008-01-29 20:20:25 有一句话很坑人——最后一组数据后面不能有空行~具体哪一句自己找一下吧... 然后虽然我的代码很难看,但是调了好多组总算过了... #include <iostream> using namespace std; int a[5000],b[5000],k; void dfs(int x) { if (x>6) { printf("%d",a[b[1]-1]); for (int i=2;i<=6;++i) printf(" %d",a[b[i]-1]); printf("\n"); return; } else for (b[x]=b[x-1]+1;b[x]<=k-x+6;++b[x]) dfs(x+1); } int main() { bool first=true; while (scanf("%d",&k),k!=0) { if (!first) printf("\n"); first=false; for (int i=0;i<k;++i) scanf("%d",&a[i]); b[0]=0; dfs(1); } return 0; } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator