打表递推poj2081
来源:互联网 发布:阿里云slb负载均衡 编辑:程序博客网 时间:2024/05/22 20:01
题目连接:http://poj.org/problem?id=2081
题目解析:要看清题目在开始做题目,还有就是开的数组要足够的大;开两个数组,一个是打表用的,一个是用判断是不是出现过了,从而判断用哪个公式。
代码如下:
#include<cstdio>#include<cstring>#include<cmath>#include<algorithm>#include<iostream>using namespace std;#define PI 3.1415927bool f[5000000]={false};__int64 taotao[500005]={0};void yujuan(){__int64 i;taotao[0]=0;for(i=0;i<=500000;i++){ if(taotao[i-1]-i>0&&!f[ taotao[i-1]-i]){taotao[i]=taotao[i-1]-i;}elsetaotao[i]=taotao[i-1]+i;f[taotao[i]]=true;}}int main(){__int64 i,j,k,m,n,sum,min,max;yujuan();while(cin>>n){if(n==-1) break;cout<<taotao[n]<<endl;}return 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)
- just a test
- kinds of Containers
- Chapter 14.关联容器set
- AndroidIPC 框架分析Binder,Service,Service manager
- OAuth认证
- 打表递推poj2081
- Hibernate generator 详解
- js window.onload 加载多个函数和追加函数
- jquery tab 水平tab分页
- C# 如何重命名(无视是否只读、等文件侠属性)文件侠,与操作
- MFC中全局变量的定义及使用
- WebServices身份认证
- Visual AssistX 安装
- GridView表头固定,表体滚动效果