TLE * N2
  • 板块P1464 Function
  • 楼主luoqiuwei
  • 当前回复5
  • 已保存回复5
  • 发布时间2020/11/17 20:42
  • 上次更新2023/11/5 07:49:23
查看原帖
TLE * N2
349726
luoqiuwei楼主2020/11/17 20:42
#include <iostream>
using namespace std;
long long w(long long a,long long b,long long c){
        if(a <= 0 or b <=0 or c <= 0){
            return 1;
        }
        if(a > 20 or b > 20 or c > 20){
            return w(20,20,20);
        }
        if(a > b and b > c){
            return w(a,b,c-1)+w(a,b-1,c-1)-w(a,b-1,c);
        }
        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(){
    long long a[100][3];
    long long b,c,d,f = 0;
    for(int x = 0;x < 100;x++){
        cin >> b >> c >> d;
        if(b == -1 and c == -1 and d == -1){
            break;
        }
        a[x][0] = b;
        a[x][1] = c;
        a[x][2] = d;
        f++;
    }
    for(int x = 0;x < f;x++){
        cout << "w(" << a[x][0] << ", " << a[x][1] << ", " << a[x][2] << ") = " << w(a[x][0],a[x][1],a[x][2]) << endl;
    }
} 
2020/11/17 20:42
加载中...