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 dynamic_study at 2009-08-11 10:42:42 on Problem 3187
#include<iostream>
#include<algorithm>
using namespace std;

int slove(int b[],int a[] ,int n)
{
    int k;
	if(n==0)
      return b[0];
	k=0;
	for(int i=0;i<n-1;i++)
	{
		b[k++]=a[i]+a[i+1];
	}
	slove(b,b,k);
	return b[0];
}

int main()
{
	int i,n,total,a[15],b[15];
	cin>>n>>total;
	for(i=0;i<n;i++)
		a[i]=i+1;
	do
	{   

		if(slove(b,a,n)==total)
		{
			for(i=0;i<n;i++)
				cout<<a[i]<<" ";
			cout<<endl;
			break;
		}
	//	system("pause");
	} while(next_permutation(a,a+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