UVa 10696 f91 (Water ver.)

Source: Internet
Author: User
Tags printf time limit

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/

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.