HDU 1398 Square Coins(母函数刷题篇)

原创 2018年04月17日 20:40:29

思路简单的母函数,多刷题多积累

#include<iostream>
#include<cstring>
#include<cstdio>
#include<algorithm>
#include<vector>
#include<set>
#include<map>
#include<queue>
#include<cmath>
using namespace std;
#define maxn 300 + 5
int n1[maxn], n2[maxn];
int main()
{
    int val[17] = {1, 4, 9, 16, 25, 36, 49, 64, 81, 100, 121, 144, 169, 196, 225, 256, 289};
    int n;
    while(scanf("%d",&n) != EOF && n)
    {
        memset(n1, 0, sizeof(n1));
        memset(n2, 0, sizeof(n2));
        for(int i = 0; i <= n; i ++)
            n1[i] = 1;
        for(int i = 1; i < 17; i ++)
        {
            for(int j = 0; j <= n; j ++)
            {
                if(n1[j])
                {
                    for(int k = 0; k + j <= n; k += val[i])
                            n2[j + k] += n1[j];
                }
            }
            memcpy(n1, n2, sizeof(n1));
            memset(n2, 0, sizeof(n2));
        }
        printf("%d\n",n1[n]);
    }
    return 0;
}

版权声明:弱鸡弱鸡弱的一匹 https://blog.csdn.net/qq_41444888/article/details/79980440

杭电ACM hdu 1398 Square Coins 解题报告(母函数)

出处:http://acm.hdu.edu.cn/showproblem.php?pid=1398 Problem Description People in Silverland use squar...
  • u012077163
  • u012077163
  • 2013-11-30 16:43:43
  • 2323

HDU:1398 Square Coins(母函数)

Square Coins Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) T...
  • zugofn
  • zugofn
  • 2017-03-17 21:37:18
  • 132

HDU -- 1398 Square Coins(母函数)

题目大意:给定一个数字n,问它可以有几种方形硬币构成方式,所谓方形硬币就是1,4,9,16.......; 思路分析:G(x)=(1+x+x^2+...+x^n)(1+x^4+x^8+...)(1+...
  • u011346442
  • u011346442
  • 2015-02-08 21:56:46
  • 190

hdu 1398 Square Coins (母函数)

题意:有面值为平方数的硬币若干,最小为1,最大为17^2,给出面值n,问能有多少种组成方案。 生成函数如下: G(x)=(1+x+x2+x3+x4+…)(1+x4+x8+x12+…)(...
  • u014679804
  • u014679804
  • 2015-04-05 15:33:00
  • 250

【HDU 1398 Square Coins】+ 母函数

Square CoinsTime Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) Tot...
  • WYK1823376647
  • WYK1823376647
  • 2017-03-16 21:36:05
  • 335

杭电 HDU ACM 1398 Square Coins

Square Coins Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) T...
  • lsgqjh
  • lsgqjh
  • 2015-04-24 20:33:00
  • 543

hdu 1398 Square Coins(母函数)

代码: #include using namespace std; int main() { int n; int a[18]; for(int i=1;i
  • xky1306102chenhong
  • xky1306102chenhong
  • 2015-06-03 20:06:59
  • 446

Hdu 1398 Square Coins 母函数

题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1398
  • u011632342
  • u011632342
  • 2014-04-25 15:06:17
  • 369

hdu 1398 Square Coins(母函数)

问题描述: People in Silverland use square coins. Not only they have square shapes but also their values...
  • u012248410
  • u012248410
  • 2013-11-19 09:18:07
  • 601
收藏助手
不良信息举报
您举报文章:HDU 1398 Square Coins(母函数刷题篇)
举报原因:
原因补充:

(最多只允许输入30个字)