Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

真水

Posted by KatrineYang at 2016-11-10 10:06:56 on Problem 1579
#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:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator