Y_QWQ_Y @ 2023-08-18 11:05:38
呵呵,懒得贴代码了,评测结果自己看
by rainbow_cat @ 2023-08-18 11:07:27
#include<bits/stdc++.h>
using namespace std;
long long a[100],b[100],c[100],i=1,vis[100][100][100];
long long w(long long a,long long b,long long c)
{
if(a<=0||b<=0||c<=0)
{
return 1;
}
if(a>20||b>20||c>20)
{
return w(20,20,20);
}
if(vis[a][b][c]!=0)
{
return vis[a][b][c];
}
if(a<b&&b<c)
{
vis[a][b][c]=w(a,b,c-1)+w(a,b-1,c-1)-w(a,b-1,c);
return vis[a][b][c];
}
vis[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 vis[a][b][c];
}
int main()
{
while(true)
{
cin>>a[i]>>b[i]>>c[i];
if(a[i]==-1&&b[i]==-1&&c[i]==-1)
{
break;
}
cout<<"w("<<a[i]<<", "<<b[i]<<", "<<c[i]<<") = "<<w(a[i],b[i],c[i])<<endl;
i++;
}
return 0;
}
by rainbow_cat @ 2023-08-18 11:07:45
@Y_QWQ_Y
by rainbow_cat @ 2023-08-18 11:08:06
可以看一下我的
by rainbow_cat @ 2023-08-18 11:08:54
但我看不到你的代码所以不能帮你改
by SealMoBurp @ 2023-08-18 11:11:03
等我长大了……
by Y_QWQ_Y @ 2023-08-18 11:15:00
#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) - w (a , b - 1 , c - 1);
}
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;
}
memset (f , 0 , sizeof (f));
printf ("%d\n" , w (a , b , c));
}
return 0;
}
诺,代码,帮我look look
by 编码落寞 @ 2023-08-18 11:21:57
@Y_QWQ_Y
f[a][b][c] = w (a , b , c - 1) + w (a , b - 1 , c) - w (a , b - 1 , c - 1);
建议再看看题面
by rainbow_cat @ 2023-08-18 11:25:16
建议再看看题面++
by Y_QWQ_Y @ 2023-08-18 11:43:50
OK,3q
by Y_QWQ_Y @ 2023-08-18 11:45:38
@[编码落寞](/user/557751) @hanruchen
3q,已关