Dart game | ||
| ||
description | ||
Darts originated in Australia. Australia's aborigines initially for hunting and hit the enemy's weapon.
A game of darts in which the players attempt to score points by throwing the darts at a target.
| ||
input | ||
The input contains several test cases.
Each test case contains an integer N ( 0 < N ≤ 1001 ) in a line.
N=0 means end of input and need not to process.
| ||
output | ||
For each test case, output how many different ways to reach zero.
| ||
sample_input | ||
5
4
3
2
1
0
| ||
sample_output | ||
6
4
1
1
0
|
至少含有一种double的取法数=总的取法-不含有double的取法。
多水的题啊!!!!数据有误!!!有误!!啊!
---------------------------------
#include <iostream>
#include <cstdio>
#include <cstring>
using namespace std;
int a[111]= {1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,25, //21
3,6,9,12,15,18,21,24,27,30,33,36,39,42,45,48,51,54,57,60, //41
2,4,6,8,10,12,14,16,18,20,22,24,26,28,30,32,34,36,38,40,50};//62
int f[1111];
int g[1111];
int n;
int main()
{
memset(f,0,sizeof(f));
memset(g,0,sizeof(g));
f[0]=1;
for (int i=0; i<62; i++)
{
for (int j=0; j<=1001-a[i]; j++)
{
if (f[j])
{
f[j+a[i]]=(f[j+a[i]]+f[j])%2011;
}
}
}
//for (int i=0;i<100;i++) printf("%d ",f[i]);
g[0]=1;
for (int i=0; i<41; i++)
{
for (int j=0; j<=1001-a[i]; j++)
{
if (g[j])
{
g[j+a[i]]=(g[j+a[i]]+g[j])%2011;
}
}
}
while (~scanf("%d",&n))
{
if (n==0) break;
printf("%d\n",(f[n]-g[n]+2011)%2011);
}
return 0;
}