UVa 10696 f91 (water ver.)

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 science. In his 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 will consist of a series of positive integers, each integer is at most 1,000,000. There will be at most 250,000 test cases. Each number is on a line on its own. The end of the input is reached when the number 0 is met. The number 0 shall not be considered as part of the test set.

Output

The program shall output each result on a line by its own, following the format given in the sample output.

Sample input

500
91
0

Sample output

f91(500) = 490
f91(91) = 91

完整代码:

/*0.078s*/

#include<cstdio>

int main(void)
{
    int N;
    while (scanf("%d", &N), N)
        if (N <= 100) printf("f91(%d) = 91\n", N);
        else printf("f91(%d) = %d\n", N, N - 10);
    return 0;
}

查看本栏目更多精彩内容:http://www.bianceng.cnhttp://www.bianceng.cn/Programming/sjjg/

以上是小编为您精心准备的的内容,在的博客、问答、公众号、人物、课程等栏目也有的相关内容,欢迎继续使用右上角搜索按钮进行搜索input
, 91
, number
, integer
, output
, at91 arm7
The
乐高10696图纸、乐高10696拼装图纸、乐高10696、乐高10696拼装拆图、乐高classic10696教程,以便于您获取更多的相关知识。

时间: 2024-07-28 12:24:44

UVa 10696 f91 (water ver.)的相关文章

UVa 11150 Cola (water ver.)

11150 - Cola Time limit: 3.000 seconds http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=24&page=show_problem&problem=2091 You see the following special offer by the convenience store: " A bottle of Choco C

UVa 12289 One-Two-Three (water ver.)

12289 - One-Two-Three Time limit: 1.000 seconds http://uva.onlinejudge.org/index.php?option=onlinejudge&Itemid=99999999&category=244&page=show_problem&problem=3710 Your little brother has just learnt to write one, two and three, in English

UVa 514 Rails (water ver.)

514 - Rails Time limit: 3.000 seconds http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=24&page=show_problem&problem=455 There is a famous railway station in PopPush City. Country there is incredibly hilly. The

UVa 11340 Newspaper (water ver.)

11340 - Newspaper Time limit: 1.000 seconds http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=24&page=show_problem&problem=2315 News agency pays money for articles according to some rules. Each character has its

UVa 10082 WERTYU (water ver.)

10082 - WERTYU Time limit: 3.000 seconds http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=24&page=show_problem&problem=1023 A common typing error is to place the hands on the keyboard one row to the right of th

UVa 79 ClockHands (water ver.)

579 - ClockHands Time limit: 3.000 seconds http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=24&page=show_problem&problem=520 The medieval interest in mechanical contrivances is well illustrated by the developme

UVa 10656 Maximum Sum (II) (water ver.)

10656 - Maximum Sum (II) Time limit: 3.000 seconds http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=24&page=show_problem&problem=1597 In a given a sequence of non-negative integers you will have to find such a

UVa 11727 Cost Cutting (water ver.)

11727 - Cost Cutting Time limit: 1.000 seconds http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=24&page=show_problem&problem=2827 Company XYZ have been badly hit by recession and is taking a lot of cost cutting

UVa 10300 Ecological Premium (water ver.)

10300 - Ecological PremiumTime limit: 3.000 seconds http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=94&page=show_problem&problem=1241 German farmers are given a premium depending on the conditions at their far