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

g++ 超时, c++ 300ms+ 附代码

Posted by 407811696 at 2011-07-27 13:05:02 on Problem 2876
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>

using namespace std;

int n;

void dfs(int n)
{
	if(n==0)
	{
		printf("-");
		return ;
	}
	dfs(n-1);
	int i,k=pow(3.0,n-1);
	for(i=1;i<=k;i++)
		printf(" ");
	dfs(n-1);
}

int main()
{
//	freopen("1.txt","r",stdin);
	while(scanf("%d",&n)!=EOF)
	{
		dfs(n);
		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