10696-f91
Time limit:3.000 seconds
Http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=24&page=show_problem &problem=1637
Background
McCarthy is a famous Theorician of computer. In him work, he defined a recursive function, called F91, that takes as input a positive integer N and returns a Positive integer defined as follows:
If n≤100, then F91 (n) = F91 (F91 (n+11));
If n≥101, then F91 (n) = n-10.
The Problem
Write a program, that computes McCarthy ' s f91.
The Input
The input tests would consist of a series of positive integers, each of the integer are at most 1,000,000. There'll is at most 250,000 test cases. Each number is on a line on its own. The end of the "input is reached" the number 0 is met. The number 0 shall not is considered as part of the test set.
Output
The program shall output is in the "a" by its own and following the format given in the sample output.
Sample input
0
Sample output
F91 (+) = 490
F91 (91) = 91
Complete code:
/*0.078s*/
#include <cstdio>
int main (void)
{
int N;
while (scanf ("%d", &n), N)
if (n <=) printf ("f91 (%d) = 91\n", n);
else printf ("f91 (%d) =%d\n", n, N-10);
return 0;
}
See more highlights of this column: http://www.bianceng.cnhttp://www.bianceng.cn/Programming/sjjg/