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

递归水过,附代码

Posted by dut200901102 at 2010-12-16 13:27:08 on Problem 2876
#include <cstdio>
#include <iostream>
#include <cstring>

using namespace std;

int p[13];
bool isdash[1000000];

void get_map(int size,int x)
{
    if(size==0)
    {
        isdash[x]=true;
        return ;
    }
    get_map(size-1,x);
    get_map(size-1,x+p[size]-p[size-1]);
}

int main()
{
    int n;
    p[0]=1;
    for(int i=1;i<13;++i)
    p[i]=p[i-1]*3;
    while(scanf("%d",&n)!=EOF)
    {
        memset(isdash,false,sizeof(isdash));
        get_map(n,0);
        for(int i=0;i<p[n];++i)
        {
            if(isdash[i])
            printf("-");
            else
            printf(" ");
        }
        printf("\n");
    }
    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