2 条题解
-
0
#include <bits/stdc++.h> using namespace std; typedef long long LL; LL f[21][21][21]; LL 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(f[a][ b ][c])return f[a][ b ][c]; if(a < b && b < c) return f[a][ b ][c] = w(a, b, c-1) + w(a, b-1, c-1) - w(a, b-1, c); else return f[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); } int main() { int a, b, c; while(scanf("%d%d%d", &a, &b, &c) != EOF) { if(a == -1 && b == -1 && c == -1)return 0; LL ans = w(a, b, c); printf("w(%d,%d,%d)=%lld\n", a, b, c, ans); } return 0; } -
0
#include<bits/stdc++.h> using namespace std; typedef long long LL; LL f[21][21][21]; LL 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(f[a][ b ][c])return f[a][ b ][c]; if(a<b&&b<c) return f[a][ b ][c]=w(a,b,c-1)+w(a,b-1,c-1)-w(a,b-1,c); else return f[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); } int main() { int a,b,c; while(scanf("%d%d%d",&a,&b,&c)!=EOF) { if(a==-1&&b==-1&&c==-1)return 0; LL ans=w(a,b,c); printf("w(%d,%d,%d)=%lld\n",a,b,c,ans); } return 0; }
- 1
信息
- ID
- 833
- 时间
- 1000ms
- 内存
- 128MiB
- 难度
- 7
- 标签
- 递交数
- 151
- 已通过
- 36
- 上传者