TOJ 1257 感受水题的力量
来源:互联网 发布:健身 知乎 编辑:程序博客网 时间:2024/04/29 07:18
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
Hint
Huge input and output, scanf( ) and printf( ) are recommended.
这道题的力量实在太大,开始不管是递归还是计算都WA。。。
结果发现输出很bug,不按常理出题而已
开始的想法是101-10=91 然后再89 90 91中找临界。后来想到了mod11的问题就简单了。
但是一直WA后,就暴力的用递归然后穷尽看。
然后发现。。。
#include<stdlib.h>#include<stdio.h>int main(){ int n = 0; while(scanf("%d",&n)){ if(n==0) break; if(n>101){ printf("f91(%d) = %d\n",n,n-10); continue; } else { printf("f91(%d) = %d\n",n,91); continue; } } system("pause"); return 0;}
- TOJ 1257 感受水题的力量
- 感受架构的力量
- 再一次感受爱的力量!
- 2007:感受互联网的力量
- 初次感受python的力量
- 感受超媒体的传播速度和力量...
- “中关村装机”感受网店的力量
- 第二届深商大会,感受互联网的力量
- 通过启动脚本来感受ASP的力量
- 真实感受了一把微博的力量
- Java开源项目(一起感受开源的力量)
- 看了“QQ概念视频(触摸版)”,感受到了WPF的力量
- 升级——从Fedora core 6到Fedora 7,感受yum的力量(一)
- 奥巴马入驻Pinterest 总统也感受到了兴趣图谱的力量
- 分形艺术能让你感受上帝的力量——新锐100设计师风达专访
- 感受移动互联的力量!手机移动销售软件—纷享销客来访进行公司及产品介绍(图文)
- NBA球员力量训练方法!感受职业球员日常训练!
- 在Android Studio上使用GSON+VOLLEY,秒处理网络数据成集合。感受框架的力量。搭配RecyclerView和SwipeRefreshLayout,实现底端加载更多,下拉刷新。
- C/S与B/S结构的区别去联系
- ASR(Automatic Speech Recognition)的相关术语
- 进程间通讯概述管道通讯信号通讯共享内存
- linux下的java反编译工具
- autoboxing and auto-unboxing of JDK1.5
- TOJ 1257 感受水题的力量
- Android 操作系统的内存回收机制
- JPgraph中文乱码问题解决
- 1013
- ubuntu 12.04 桌面版关闭图形界面
- Oracle 特殊符号
- 怎样练习一万小时
- Removing OpenJDK JRE Ubuntu 10.10 EC2 amazon and install Sun Java 6 JRE JDK
- Android初级教程_获取Android控件的宽和高