Differences between revisions 1 and 2
 ⇤ ← Revision 1 as of 2008-10-08 14:42:50 → Size: 1712 Editor: 218 Comment: ← Revision 2 as of 2008-10-08 14:44:45 → ⇥ Size: 2062 Editor: 218 Comment: Deletions are marked like this. Additions are marked like this. Line 50: Line 50: hdu1028 hdu1085 Line 53: Line 53: N=a[1]+a[2]+...+a[m],a[i]>0,1<=m<=N。总共有多少种不同的方程？4=1+3=3+1是同一种。 面值为1,2,5的硬币分别有num1,num2,num3个，求由这些硬币不能得到的最小面值。 Line 57: Line 56: f(x)=(1+x+x^2+...)(1+x^4+x^8+...)..(1+x^289+...)其中x^n次方的系数就是构成总值为n的方程总数。 f(x)=(1+x+x^2+...x^num1)(1+x^2+x^4+...+x^2num2)(1+x^5+...x^5num3)其中x^n次方的系数就是构成总值为n的方法总数。 Line 63: Line 62: const int N=130; const int N=8010;int num[3]; Line 67: Line 67: void Poly() int Init() Line 69: Line 69: scanf("%d %d %d",&num[0],&num[1],&num[2]);    if(num[1]+num[2]+num[3]==0)        return 0;    memset(a,0,sizeof(a));    memset(b,0,sizeof(b)); Line 70: Line 75: for(int i=0;i

/*

hdu1085
ymc 2008/09/25

*/
#include <iostream>
using namespace std;
int n1,n2,n5;
int Init()
{
scanf("%d %d %d",&n1,&n2,&n5);
if(n1+n2+n5==0)
return 0;
return 1;
}
void Solve()
{
if(n1==0)
{
printf("1\n");
return;
}
int n=n1+n2+n2;
if(n<4)
{
printf("%d\n",n+1);
return;
}
printf("%d\n",5*n5+n+1);
}
int main()
{
while(Init())
{
Solve();
}
}

/*

hdu1085
ymc 2008/09/25

f(x)=(1+x+x^2+...x^num1)(1+x^2+x^4+...+x^2num2)(1+x^5+...x^5num3)

*/
#include <iostream>
using namespace std;
const int N=8010;
int num[3];
int a[N];
int b[N];
int c[N];
int Init()
{
scanf("%d %d %d",&num[0],&num[1],&num[2]);
if(num[1]+num[2]+num[3]==0)
return 0;
memset(a,0,sizeof(a));
memset(b,0,sizeof(b));
memset(c,0,sizeof(c));
for(int i=0;i<=num[0];i++)
a[i]=1;
int n=num[1]+num[1];
for(int i=0;i<=n;i+=2)
b[i]=1;
for(int i=0;i<=num[0];i++)
for(int j=0;j<=n;j=j+2)
c[i+j]+=a[i]*b[j];

n=5*num[2];
memset(b,0,sizeof(b));
for(int i=0;i<=n;i+=5)
b[i]=1;
memset(a,0,sizeof(a));
int n1=num[0]+num[1]+num[1];
for(int i=0;i<=n1;i++)
for(int j=0;j<=n;j+=5)
a[i+j]+=c[i]*b[j];
return 1;
}
int main()
{
while(Init())
{
int k=0;
while(1)
{
if(a[k]==0)
{
printf("%d\n",k);
break;
}
k++;
}
}
}

hdu1085 参考答案 (last edited 2008-10-08 14:44:45 by 218)

ch3n2k.com | Copyright (c) 2004-2020 czk.