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 luchenqun at 2010-08-06 21:22:48 on Problem 2346
首先,写个程序算出N=2,4,6,8,10时一共有多少张Lucky Tickets。
演示一个当N=10有多少张Lucky Tickets。
#include<iostream>
using namespace std;
int main()
{
	int count=0,a,b,c,d,e,f,g,h,i,j;
	for(a=0;a<=9;a++)
	for(b=0;b<=9;b++)
	for(c=0;c<=9;c++)
	for(d=0;d<=9;d++)
	for(e=0;e<=9;e++)
	for(f=0;f<=9;f++)
	for(g=0;g<=9;g++)
	for(h=0;h<=9;h++)
	for(i=0;i<=9;i++)
	for(j=0;j<=9;j++)
		if(a+b+c+d+e==f+g+h+i+j)
			count++;
	cout<<count<<endl;
	return 0;
}

然后就是流氓打表法:
#include<iostream>
using namespace std;
int main()
{
	int a[]={0,10,670,55252,4816030,432457640},n;
	while(cin>>n)
		cout<<a[n/2]<<endl;
	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