| ||||||||||
| Online Judge | Problem Set | Authors | Online Contests | User | ||||||
|---|---|---|---|---|---|---|---|---|---|---|
| Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest | |||||||||
真水#include <iostream>
using namespace std;
int val[25][25][25];
bool jsed[25][25][25] = {0};
int getVal(int a, int b, int c){
if(a<=0||b<=0||c<=0) return 1;
if(a>20||b>20||c>20) return getVal(20,20,20);
if(jsed[a][b][c]) return val[a][b][c];
int res;
if(a<b && b<c){
res = getVal(a,b,c-1)+getVal(a,b-1,c-1)-getVal(a,b-1,c);
}
else{
res = getVal(a-1,b,c)+getVal(a-1,b-1,c)+getVal(a-1,b,c-1)-getVal(a-1,b-1,c-1);
}
jsed[a][b][c]=1;
val[a][b][c]=res;
return res;
}
int main() {
int a,b,c;
while(1){
cin >> a >> b >> c;
if(a==-1 && b==-1 && c==-1) break;
cout << "w(" << a << ", " << b << ", " << c << ") = " << getVal(a,b,c) << endl;
}
return 0;
}
Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator