zoukankan      html  css  js  c++  java
  • HDU 1398 Square Coins

    题目大意:有面值分别为。1,4,9,.......17^2的硬币无数多个。问你组成面值为n的钱的方法数。

    最简单的母函数模板题:

    #include <cstdio>   
    #include <cstring>  
    using namespace std;  
    int c1[305],c2[305],n;  
    int main(){  
        while(scanf("%d",&n),n){  
            for(int i=0;i<=n;i++)c1[i]=1,c2[i]=0;  
            for(int i=2;i<18;i++){  
                for(int j=0;j<=n;j++){  
                    for(int k=0;k+j<=n;k+=i*i)c2[j+k]+=c1[j];  
                }  
                memcpy(c1,c2,sizeof c2); memset(c2,0,sizeof c2);  
            }  
            printf("%d
    ",c1[n]);  
        }  
    }
    
  • 相关阅读:
    js中级-函数封装
    js中级-11.7
    js中级-11.5
    js中级-11.2
    js中级-this
    js中级-作用域链
    10.23
    10.22
    10.19js
    10.18
  • 原文地址:https://www.cnblogs.com/forever97/p/3662345.html
Copyright © 2011-2022 走看看