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 Bang1314 at 2018-04-01 14:15:12 on Problem 1579
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<queue>
using namespace std;

#define PI acos(-1.0)
#define INF 0x3f3f3f3f
#define ll long long
#define lowbit(i) i&(-i)
#define lson l,m,rt<<1
#define rson m+1,r,rt<<1|1

const int maxn=65;
const int mod=1e9+7;
const double eps=1e-6;

int vis[22][22][22];

int solve(int a,int b,int c){
    if(a<=0||b<=0||c<=0) return 1;
    if(a>20||b>20||c>20) return solve(20,20,20);
    if(vis[a][b][c]!=-1) return vis[a][b][c];
    if(a<b&&b<c) return vis[a][b][c]=(solve(a,b,c-1)+ solve(a,b-1,c-1)-solve(a,b-1,c));
    else return vis[a][b][c]=(solve(a-1,b,c)+ solve(a-1,b-1,c) + solve(a-1,b,c-1)-solve(a-1,b-1,c-1));
}
int main(){
    int a,b,c;
    memset(vis,-1,sizeof(vis));
    while(~scanf("%d%d%d",&a,&b,&c)&&(a!=-1||b!=-1||c!=-1)){
        printf("w(%d, %d, %d) = %d\n",a,b,c,solve(a,b,c));
    }
    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