全部超时了,请大佬们看一看,谢谢
  • 板块P1464 Function
  • 楼主wkl20110514
  • 当前回复6
  • 已保存回复6
  • 发布时间2022/12/21 08:48
  • 上次更新2023/10/24 07:04:37
查看原帖
全部超时了,请大佬们看一看,谢谢
775044
wkl20110514楼主2022/12/21 08:48

全部超时了,请大佬们看一看,谢谢

#include <cstdio>
#include <algorithm>
#include <iostream>
#include <cmath>
#define LL long long
using namespace std;
LL a[3],b;
LL w(LL a,LL b,LL c){
    if(a<=0||b<=0||c<=0)return 1;
    else if(a>20||b>20||c>20)return w(20,20,20);
    else if(a<b&&b<c)return w(a,b,c-1)+w(a,b-1,c-1)-w(a,b-1,c);
    else return w(a-1,b,c)+w(a-1,b-1,c)+w(a-1,b,c-1)-w(a-1,b-1,c-1);
}
int main(){
    for(int i;i==i;){
        scanf("%lld%lld%lld",&a[0],&a[1],&a[2]);
        if(a[0]==-1&&a[1]==-1&&a[2]==-1)return 0;
        printf("w(%lld, %lld, %lld) = %lld\n",a[0],a[1],a[2],w(a[0],a[1],a[2]));
    }
}

好像输入50,50,50时时间就超了

2022/12/21 08:48
加载中...