1910 Recursive Functions
time limit: 1 sspace limit: 128000 KBtitle level: Golden GoldTitle Description
Description
For a recursive function w (A, B, c).
If a <= 0 or b <= 0 or C <= 0 returns the value 1.
If a > B > or C > 20 returns W (20,20,20).
If a < b and B < C return W (A, B, c? 1) + W (A, B, 1, c? 1)? W (A, B? 1, c),
In other cases, return W (a? 1, B, c) + W (a? 1, b? 1, C) + W (a? 1, B, c? 1)? W (a? 1, b-1, c-1)
This is a simple recursive function, but it may be problematic to implement.
Enter a description
Input Description
There will be several lines. Three numbers per line, indicating a, B, C. and 1,? 1,? 1 ends
Output description
Output Description
Output several lines, and note the spaces in the various.
Sample input
Sample Input
1 1 1
2 2 2
-1-1-1
Sample output
Sample Output
W (1, 1, 1) = 2
W (2, 2, 2) = 4
Data range and Tips
Data Size & Hint
A, B, C <, Task < 11
Portal ->>  
^
|
This problem uses the mathematical thinking is my hand (Chao) writes (xi).
#include <iostream>#include<cstdlib>using namespacestd;intWintAintBintc) {    if(a<=0|| b<=0|| c<=0)return 1; Else if(a> -|| B> -|| C> -)returnW -, -, -); Else if(a<=b| | a<=c) {intI=1;  for(intj=0; j<a;j++) I*=2; returni; }    Else returnW (A-1, B,c) +w (A-1, B-1, c) +w (A-1, b,c-1)-W (A1, B-1, C-1);}intMain () {inta[ One][3],i,j;  for(i=0;i< One; i++) {cin>>a[i][0]>>a[i][1]>>a[i][2]; if(a[i][0]==-1&&a[i][1]==-1&&a[i][2]==-1) Break; }        for(j=0; j<i;j++) cout<<"W ("<<a[j][0]<<", "<<a[j][1]<<", "<<a[j][2]<<") = "<<w (a[j][0],a[j][1],a[j][2]) <<Endl; return 0;}Click to expand
The path of Practice ~ Buckle to Ace 1910 recursive function