Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

Re:PE????求大牛帮忙(附代码)

Posted by SCSE10_Candybox at 2011-02-15 23:00:06 on Problem 2245
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:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator