Codevs1186 F函数题解
来源:互联网 发布:淘宝店铺能叫旗舰店吗 编辑:程序博客网 时间:2024/06/05 10:33
题目描述 Description
最近cyz一直在研究一个函数,函数是这样的
If X<=100 F[x]=F[F[x+11]]
If X>=101 F[x]=X-10
现在cyz需要知道一些值对应的函数值。输入描述 Input Description
输入包括若干行(最多2500000行),每行一个正整数X(X≤106 )。
最后一行以0结束.注意0不是要求的X,只是一个结束标记。输出描述 Output Description
对应每个要求的X值,每行输出一个对应的F[x]函数值。样例输入 Sample Input
100
101
0样例输出 Sample Output
91
91题解
刚开始看到题时想到的是记忆化搜索,于是这样就过了。
#include <cstdio>using namespace std;int f[101];int F(int x){ if(x > 100) return x - 10; if(f[x]) return f[x]; return f[x] = F(F(x + 11));}int main(){ int x; while(scanf("%d", &x) == 1) if(x != 0) printf("%d\n", F(x)); return 0;}
- 这其实是著名的91函数,x<=100时函数值一直是91……
0 0
- Codevs1186 F函数题解
- SDKD TeamContest F 题解
- 【题解】F(x)
- F函数
- 并查集训练题解(F-J)
- C,D,F,G,H题 题解
- CodeForces 589F Gourmet and Banquet 题解
- 16 hrbust邀请赛D、F题解
- Gym 101147F Bishops Alliance 题解
- Codeforces 632F Magic Matrix 题解
- Codeforces 598F Cut Length 题解
- F# 函数编程语言
- F# 函数式编程
- c语言函数--F
- django F() 函数
- F函数(水题)
- Prototype使用$F()函数
- jquery的$F()函数
- 双向链表的简单操作
- WordPress foxpay 收费下载资源插件 vip会员功能/收费下载/收费查看/联盟推广+前端用户中心 支付宝/财付通/贝宝/网银[更新至v4.5]
- 重绘的实现
- Spring+hibernate+quartz 通过sessionFactory定时操作数据库
- Hadoop之MapReduce—Wordcount
- Codevs1186 F函数题解
- ps转手绘
- Xib中调整button的imageView和TitleLabel的位置
- 项目Bug 解决
- 旋转数组的最小值问题
- poco 数据库连接池
- 在velocity使用toolbox.xml
- 类的委托加载机制
- ubuntu 源