POJ2081
来源:互联网 发布:php require once地址 编辑:程序博客网 时间:2024/05/16 14:57
水,按题意打表就好了,注意vis[]数组要开大点 就好了.
#include <iostream>#include <cmath>#include <cstring>#define MAXN 500005#define LL long longusing namespace std;LL sq[MAXN];LL vis[MAXN*10];void init(){ LL i; memset(vis,0,sizeof(vis)); sq[0]=0; vis[0]=1; for(i=1;i<=500000;i++) { LL tem=sq[i-1]-i; if(tem>0&&vis[tem]==0) { sq[i]=tem; vis[tem]=1; } else { sq[i]=sq[i-1]+i; vis[sq[i-1]+i]=1; } }}int main(){ int n; init(); while(cin>>n&&n!=-1) { cout<<sq[n]<<endl; } return 0;}
0 0
- poj2081
- poj2081
- poj2081
- poj2081
- poj2081
- POJ2081
- poj2081
- 打表递推poj2081
- poj2081 (3356K)
- poj2081(据说是DP)
- POJ2081:Recaman's Sequence
- poj2081 Recaman's Sequence
- POJ2081 Recaman's Sequence
- poj2081 Recaman's Sequence
- POJ2081 2081 Recaman's Sequence
- Recaman's Sequence(poj2081)
- 北大ACM poj2081 Recaman's Sequence
- 【poj2081】Recaman's Sequence (动态规划DP)
- P123.36T 切换时间显示
- spring security ajax 跳转登录页
- shell编程
- HDU5052 Yaoge’s maximum profit(树链剖分)点权更新,经典题
- Codeforces Round #162 (Div. 1) B dp
- POJ2081
- 今天在CentOS6.4操作系统下安装了Oracle客户端
- 循环队列的基本用法(链式存储结构)
- Ubuntu 12.04(64位)安装Android Studio 全过程
- linux grep命令详解
- C++基础
- 自学宝典:10个学习Android开发的网站推荐
- 电信141p123第36题
- JAVA中给 JPanel 加标题头