会飞的禽兽 @ 2018-11-29 17:37:03
using namespace std; long long ans[30][30][30]={0,0,0}; int w(int a,int b,int c) { //cout<<"w(a,b,c)="<<a<<" "<<b<<" "<<c<<endl; if (a<=0||b<=0||c<=0) return 1; if (ans[a][b][c]!=0) return ans[a][b][c]; if (a<b&&b<c) { ans[a][b][c]=w(a,b,c-1)+w(a,b-1,c-1)+w(a,b-1,c); return ans[a][b][c]; } ans[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 ans[a][b][c]; }
int main() { long long a,b,c; memset(ans,0,sizeof(ans)); while (cin>>a>>b>>c) { if (a==-1&&b==-1&&c==-1) break; printf("w(%lld, %lld, %lld) = ",a,b,c); if (a>20||b>20||c>20) a=b=c=20; int aaa=w(a,b,c); printf("%d\n",aaa); } return 0; }
by ⚡小林孑⚡ @ 2018-11-29 18:01:55
#include<bits/stdc++.h>
using namespace std;
long long jy[200][200][200],a,b,c;
int move(int a,int b,int c)
{
if (jy[a][b][c]!=0) return jy[a][b][c];
if (a<=0||b<=0||c<=0) {return 1;}
if (a>20||b>20||c>20) {if (jy[a][b][c]==0) jy[a][b][c]=move(20,20,20);return move(20,20,20);}
if (a<b&&b<c) {if (jy[a][b][c]==0) jy[a][b][c]=move(a,b,c-1)+move(a,b-1,c-1)-move(a,b-1,c);return move(a,b,c-1)+move(a,b-1,c-1)-move(a,b-1,c);}
if (jy[a][b][c]==0) jy[a][b][c]=move(a-1,b,c)+move(a-1,b-1,c)+move(a-1,b,c-1)-move(a-1,b-1,c-1);
return move(a-1,b,c)+move(a-1,b-1,c)+move(a-1,b,c-1)-move(a-1,b-1,c-1);
}
int main()
{
while(1)
{
cin>>a>>b>>c;
if (a==-1&&b==-1&&c==-1) return 0;
cout<<"w("<<a<<", "<<b<<", "<<c<<") = ";
if (a<=0||b<=0||c<=0) {cout<<1<<endl;continue;}
cout<<move(a,b,c)<<endl;
if (jy[a][b][c]!=0) jy[a][b][c]=move(a,b,c);
}
}
by sss7020 @ 2018-11-29 18:14:21
#include<cstdio>
#include<iostream>
#include<cstring>
#define _ 0
#define ll long long
using namespace std;
ll rpt[25][25][25];
ll w(ll a,ll b,ll c){
if(a<=0||b<=0||c<=0) return 1;
else if(rpt[a][b][c]!=0) return rpt[a][b][c];
else if(a>20||b>20||c>20) rpt[a][b][c]=w(20,20,20);
else if(a<b&&b<c) rpt[a][b][c]=w(a,b,c-1)+w(a,b-1,c-1)-w(a,b-1,c);
else rpt[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 rpt[a][b][c];
}
int main(){
ll x,y,z;
while(1){
memset(rpt,0,sizeof(0));
scanf("%lld%lld%lld",&x,&y,&z);
if(x==-1&&y==-1&&z==-1)break;
if(x>=21)
x=21;
if(y>=21)
y=21;
if(z>=21)
z=21;
long long ans=w(x,y,z);
cout<<"w("<<x<<", "<<y<<", "<<z<<") = "<<ans<<endl;
}
return 0;
}
by Victorique_De_Blois @ 2018-11-30 12:15:29
@会飞的禽兽 光标选中你的代码,然后按两下TAB即可,或者在编辑文本的框里面(就是你打字的地方)有一个
< / >
点进去,相信我你会操作的QWQ