范德萨发而为
全部博文(392)
分类:
2009-12-22 19:12:32
{
dfs(current + i);
}
}
int main(int argc, char *argv[])
{
int i, t;
while (scanf("%d %d %d", &n, &m, &p))
{
if (-1 == n && -1 == m && -1 == p)
break;
memset(fruit, 0, sizeof(fruit));
count = 0;
for (i=0 ; i
scanf("%d", &t);
fruit[t] = 1;
}
dfs(1);
printf("%d\n", count);
}
}
/* 很简单的dp,注意输出是long long,初始化条件method[0]=1 */
#include
#include
int fruit[1010];
long long method[1010];
long long dp(int n, int p)
{
int i, j;
for (i=1 ; i<=n ; i++)
{
for (j=i-p ; j {
if (j < 0 || 1 == fruit[j] || 1 == fruit[i])
continue;
method[i] += method[j];
}
}
return method[n];
}
int main(int argc, char *argv[])
{
int n, m, p, i, t;
while (scanf("%d %d %d", &n, &m, &p))
{
if (-1 == n && -1 == m && -1 == p)
break;
memset(fruit, 0, sizeof(fruit));
memset(method, 0, sizeof(method));
method[0] = 1;
for (i=0 ; i
scanf("%d", &t);
fruit[t] = 1;
}
printf("%lld\n", dp(n, p));
}
}