| ||||||||||
| 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 | |||||||||
递归水过,附代码#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: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator