hack来喽~

P1464 Function

2012zxt @ 2023-10-19 11:42:01

9223372036854775807 9223372036854775807 9223372036854775807
-1 -1 -1

可以卡掉第八篇题解

#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <cmath>
using namespace std;
int a[21][21][21] = {1};
int w(int x,int y,int z)//直接判断递归搜索即可
{
    if(x<=0||y<=0||z<=0) return 1;
    else if(x>20||y>20||z>20) return a[20][20][20]?a[20][20][20]:a[20][20][20]=w(20,20,20);
    else if(x<y&&y<z) return (a[x][y][z-1]?a[x][y][z-1]:a[x][y][z-1]=w(x,y,z-1)) + (a[x][y-1][z-1]?a[x][y-1][z-1]:a[x][y-1][z-1]=w(x,y-1,z-1)) - (a[x][y-1][z]?a[x][y-1][z]:a[x][y-1][z]=w(x,y-1,z));
    else return (a[x-1][y][z]?a[x-1][y][z]:a[x-1][y][z]=w(x-1,y,z)) + (a[x-1][y-1][z]?a[x-1][y-1][z]:a[x-1][y-1][z]=w(x-1,y-1,z)) + (a[x-1][y][z-1]?a[x-1][y][z-1]:a[x-1][y][z-1]=w(x-1,y,z-1)) - (a[x-1][y-1][z-1]?a[x-1][y-1][z-1]:a[x-1][y-1][z-1]=w(x-1,y-1,z-1));
    return 1;
}
int main()
{
    int  d,b,c;
    while(scanf("%d%d%d", &d, &b, &c) && (d + 1) || (b + 1) || (c + 1)){
    printf("w(%d, %d, %d) = %d\n", d, b, c, w(d, b, c));
    }
    return 0;
}

by 2012zxt @ 2023-10-19 11:42:38

@小粉兔 hack来喽~

@chen_zhe


by 2012zxt @ 2023-10-19 11:44:03

@一扶苏一 @mrsrz


by 小粉兔 @ 2023-10-20 00:07:34

@2012zxt 请 at 题目管理志愿者


|