poj 2081 Recaman's Sequence
2016-03-25 18:15
316 查看
開始还以为暴力做不出来,须要找规律,找了半天找不出来。原来直接暴力。。
代码例如以下:
代码例如以下:
#include<stdio.h> int a[1000050]; int b[100000000]={0}; int main() { int i,k; a[0]=0; for(i=1;i<=500000;i++) { a[i]=a[i-1]-i; if(a[i-1]-i>0&&!b[a[i-1]-i]) a[i]=a[i-1]-i; else a[i]=a[i-1]+i; b[a[i]]=1; } while(scanf("%d",&k)!=EOF) { if(k==-1) break; else printf("%d\n",a[k]); } return 0; }
相关文章推荐
- Web 快速开发框架 WebBuilder 7 发布
- multidex导入至build失败问题
- lintcode: Implement Queue by Two Stacks
- uint8、double、mat2uint、imhist绘直方图w恩替藐视
- JAVA顺序表(Sequential List)操作
- Android4.42-Setting源码分析之蓝牙模块Bluetooth(下)
- 使用SOAPUI测试WEBAPI接口
- web UI技术方案备忘
- 能否在非UI线程更新界面呢?
- Hootsuite(互随社交)
- PreferenceActivity 中的 onBuildHeaders() 调用时机
- Hootsuite(互随社交)
- Hootsuite(互随社交)
- leetcode之Repeated DNA Sequences
- Generate a hash from unique ID
- [leetcode] 272. Closest Binary Search Tree Value II 解题报告
- 五种创建UIImage的类方法
- 关于easyUI的combbobox下拉框多选时,后台获取下拉框的值获取的问题
- ios学习总结(2) -- UIButton的使用
- ios学习总结(2) -- UIButton的使用