HDU--1028 Ignatius and the Princess III

来源:互联网 发布:网络金融营销模式 编辑:程序博客网 时间:2024/05/18 01:21
#include<cstdio>#include<cstring>#include<string>#include<iostream>#include<cmath>#include<algorithm>using namespace std;typedef long long LL;const LL MAXN = 120 ;int F[MAXN+1];int P[MAXN+1] ;void Prepare() {    LL i , j , k , s , o ;    P[0] = 1 ;    for ( i = 1 ; i <= MAXN ; i ++ ) {        j = 1 , k = 1 , s = 0 , o = -1 ;        for ( ; j > 0 ; k ++ , o *= -1 ) {            j = i - (3*k*k+k)/2 ;            if ( j >= 0 ) s -= o * P[j] ;            j = i - (3*k*k-k)/2 ;            if ( j >= 0 ) s -= o * P[j] ;        }        P[i] = s ;    }}int main() {    Prepare() ;    int Test , N ;    while ( cin>>N ) {        printf("%d\n",P[N]);    }}


怎么说呢。看到这道题就想到了昨天多校的1009............一看还真就一样。

还是打表题,因为昨天多校是2KMS而,今天是1KMS。

所以还是把,MAXN的值从10000降到了125,足够了

简单来说是一个母函数的题,大致就是循环递推的过程。