100,hack全WA求助求助~~~

P1464 Function

77Glorious @ 2023-11-03 21:53:30

#include<bits/stdc++.h>
using namespace std;

unsigned long long mmr[25][25][25]={0};

unsigned long long w(int a,int b,int c){
    if(a<=0||b<=0||c<=0) return 1;
    if(a>20||b>20||c>20) return w(20,20,20);
    if(mmr[a][b][c]) return mmr[a][b][c];
    if(a<b&&b<c) mmr[a][b][c]=w(a,b,c-1)+w(a,b-1,c-1)-w(a,b-1,c);
    else mmr[a][b][c]=w(a-1,b,c)+w(a-1,b-1,c)+w(a-1,b,c-1)-w(a-1,b-1,c-1);
    return mmr[a][b][c];//记忆化 
}
unsigned long long a,b,c; 
int main(){
    while(1){//无限循环
         cin>>a>>b>>c;
         if(a==-1&&b==-1&&c==-1) break;
        printf("w(%d, %d, %d) = %d\n",a,b,c,w(a,b,c));
    }

    return 0;
}

by Y_QWQ_Y @ 2023-11-05 16:29:47

要开long long


by HugeSB @ 2023-11-08 19:11:28

ull无法储存数的正负


by a1090251107 @ 2023-11-13 20:32:20

hack的输入数据是2147483648 1 1 -1 -1 -1,这里的a刚好超过了int(= =没搞懂这东西有啥意义),所以传参的时候形参要开long long这样才能在第一波递归引用的时候保证数据范围


by 2911841277wxh @ 2024-01-31 16:38:24

@a1090251107 谢谢你,找了一圈以为都开了long long,原来传参的地方没开


|