Y_QWQ_Y @ 2023-08-18 11:05:38
呵呵,懒得贴代码了,评测结果自己看
by Y_QWQ_Y @ 2023-08-18 12:07:56
但还是没AC
by Y_QWQ_Y @ 2023-08-18 12:08:30
#include<bits/stdc++.h>
using namespace std;
int a , b , c;
int f[33][33][33];
int w (int a , int b , int c)
{
if (a <= 0 || b <= 0 || c <= 0)
{
return 1;
}
else if (f[a][b][c] > 0)
{
return f[a][b][c];
}
else if (a > 20 || b > 20 || c > 20)
{
f[a][b][c] = w (20 , 20 , 20);
}
else if (a < b && b < c)
{
f[a][b][c] = w (a , b , c - 1) + w (a , b - 1 , c - 1) - w (a , b - 1 , c);
}
else
{
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);
}
return f[a][b][c];
}
int main()
{
int sum = 1;
for (int i = 1; i <= 20; ++ i)
{
sum *= 2;
f[i][i][i] = sum;
}
while (scanf ("%d %d %d" , &a , &b , &c))
{
if (a == -1 && b == -1 && c == -1)
{
break;
}
printf ("w(%d, %d, %d) = " , a , b , c);
if (a > 20)
{
a = 21;
}
if (b > 20)
{
b = 21;
}
if (c > 20)
{
c = 21;
}
printf ("%d\n" , w (a , b , c));
}
return 0;
}
by 编码落寞 @ 2023-08-18 12:38:14
@Y_QWQ_Y 可以kailong long试试
by AnnaQ @ 2023-09-06 10:09:29
@编码落寞 Yes
by Y_QWQ_Y @ 2023-11-05 16:34:40
但是改完似乎尚未AC,今天突然发现没开long long
#include<bits/stdc++.h>
#define int long long
using namespace std;
int a , b , c;
int f[33][33][33];
int w (int a , int b , int c)
{
if (a <= 0 || b <= 0 || c <= 0)return 1;
else if (f[a][b][c] > 0)return f[a][b][c];
else if (a > 20 || b > 20 || c > 20)return f[20][20][20];
else if (a < b && b < c)f[a][b][c] = w (a , b , c - 1) + w (a , b - 1 , c - 1) - w (a , b - 1 , c);
else 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);
return f[a][b][c];
}
signed main()
{
int sum = 1;
for (int i = 1; i <= 20; ++ i){sum *= 2;f[i][i][i] = sum;}
while (scanf ("%lld %lld %lld" , &a , &b , &c))
{
if (a == -1 && b == -1 && c == -1)break;
printf ("w(%lld, %lld, %lld) = " , a , b , c);
a = a > 20 ? 21 : a;
b = b > 20 ? 21 : b;
c = c > 20 ? 21 : c;
printf ("%lld\n" , w (a , b , c));
}
return 0;
}
呵呵