1 1 12 2 2Example Output
24Hint
Author
qinchuan
01 | #include<stdio.h> |
02 |
03 | int x[31][31][31]={0}; |
04 | int f( int a, int b, int c) |
05 | { |
06 | if (a <= 0||b <= 0||c <= 0) |
07 | return 1; |
08 | else if (a>20||b>20||c>20) |
09 | return f(20,20,20); |
10 | else if (x[a][b][c]) return x[a][b][c]; |
11 | else if (a<b&&b<c) |
12 | return x[a][b][c]=f(a,b,c-1)+f(a,b-1,c-1)-f(a,b-1,c); |
13 | else |
14 | return x[a][b][c]=f(a-1,b,c)+f(a-1,b-1,c)+f(a-1, b, c-1)-f(a-1,b-1,c-1); |
15 | } |
16 |
17 | int main() |
18 | { |
19 | int a,b,c; |
20 | if (a<30||b<30||c<30) |
21 | { |
22 | while (~ scanf ( "%d %d %d" ,&a,&b,&c)) |
23 | { |
24 | printf ( "%d/n" ,f(a,b,c)); |
25 | } |
26 | } |
27 | return 0 ; |
28 | } |
29 |
30 |
新闻热点
疑难解答