UVa 10696 f91 (water ver.)
来源:互联网 发布:淘宝仓管是做什么的 编辑:程序博客网 时间:2024/05/20 02:51
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
500910
Sample output
f91(500) = 490f91(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;}
- UVa 10696 f91 (water ver.)
- UVA 10696 - f91
- UVa 10696 - f91
- UVa 10082 WERTYU (water ver.)
- UVa 79 ClockHands (water ver.)
- UVa 11340 Newspaper (water ver.)
- UVa 514 Rails (water ver.)
- UVa 11150 Cola (water ver.)
- UVa 10300 Ecological Premium (water ver.)
- UVa 414 Machined Surfaces (water ver.)
- UVa 490 Rotating Sentences (water ver.)
- UVa 445 Marvelous Mazes (water ver.)
- UVa 488 Triangle Wave (water ver.)
- UVa 10783 Odd Sum (water ver.)
- UVa 457 Linear Cellular Automata (water ver.)
- UVa 621 Secret Research (water ver.)
- UVa 11044 Searching for Nessy (water ver.)
- UVa 102 Ecological Bin Packing (water ver.)
- 《C++程序设计语言》5.9_13 定义一个struct Date 以保存日期的轨迹
- Linux命令大全
- MyEclipse 8.5 下编写JMF框架USB摄像头视频处理遇到JPEGImageEncoder编译问题Access restriction
- JPEGImageEncoder编译问题Access restriction
- 适配器模式
- UVa 10696 f91 (water ver.)
- gdb调试步骤
- 毕业生必知二三事。给即将毕业的师弟师妹看看,很有用的~~~~
- 《C++程序设计语言》6.6_3 (名字,值)对
- RvSIP初始化流程
- 《C++程序设计语言》6.6_4 按位逻辑运算
- 常见的Hash算法
- 删除元素.
- iframe的父页面、子页面相互调用