poj 2081 Recaman's Sequence(DP:水水更健康)
来源:互联网 发布:网络女生翻唱歌手 编辑:程序博客网 时间:2024/06/05 05:40
直接打表500000个数据即可
判别数组需要开的大一点,以免RE
代码如下:
#include <cstdio>#include <cstring>#define MAXN 10000000using namespace std;bool vis[MAXN];int a[500100];void init() { a[0] = 0; memset(vis, false, sizeof(vis)); for(int i=1; i<=500000; ++i) { int tmp = a[i-1]-i; if(tmp>0 && !vis[tmp]) a[i] = tmp; else a[i] = a[i-1]+i; vis[a[i]] = true; }}int main(void) { init(); int n; while(scanf("%d", &n) && (n!=-1)) { printf("%d\n", a[n]); } return 0;}
0 0
- poj 2081 Recaman's Sequence(DP:水水更健康)
- POJ 2081 Recaman's Sequence(水题)
- POJ 2081 Recaman's Sequence(水~)
- POJ 2081 Recaman's Sequence
- poj 2081 Recaman's Sequence
- POJ 2081 Recaman's Sequence
- poj 2081 :Recaman's Sequence
- poj 2081Recaman's Sequence
- poj 2081 Recaman's Sequence
- POJ 2081 Recaman's Sequence
- POJ-2081:Recaman's Sequence
- POJ-2081-Recaman's Sequence
- poj 2081 Recaman's Sequence
- POJ 2081 Recaman's Sequence
- POJ 2081 Recaman's Sequence
- POJ 2081 Recaman's Sequence
- poj 2081 Recaman's Sequence
- POJ 2081 Recaman's Sequence
- 医疗时鲜资讯:关注医疗未来新趋势(2)
- HDU 1869 六度分离
- 朗玛信息等6家获牌
- Linux系统上安装MySQL
- 丰田一绝 - 28万行代码竟有1万多全局变量,庞大的bug培养基地
- poj 2081 Recaman's Sequence(DP:水水更健康)
- JAVA网络编程——InetAddress、InetSocketAddress和URL
- HDU 2066 一个人的旅行
- C++类的大小
- 十天学习PHP之第二天
- sdfsdf
- 中国剩余定理
- [POJ 3264]Balanced Lineup(ST算法求RMQ)
- hdu 4496 D-City