POJ 2081 Recaman's Sequence
来源:互联网 发布:forge软件 下载 编辑:程序博客网 时间:2024/06/07 13:31
很简单题,直接暴力运算。前人们都说这道题是简单DP,比较有道理
不过我觉得这道题好像模拟以下计算过程就完事了,不过想起来DP也是在模拟计算过程。。。结果我在网上也没查到模拟法的定义
这道题比较有意思的是数组范围,超~~~~大,本地根本无法通过,不过OJ上可以
#include<stdio.h>#include<string.h>#define max 10000000#define N 500002int a[N];char vis[max]; // 数组要开成全局int main(void){int n, m;memset( vis, 0, sizeof(vis));memset( a, 0, sizeof(a));for( m = 1; m < N; m++){if( a[m-1] - m > 0 && !vis[a[m-1] - m]){a[m] = a[m-1] - m;vis[a[m]] = 1;}else{a[m] = a[m-1] + m;vis[a[m]] = 1;}}while( scanf("%d", &n) != EOF && n != -1){printf("%d\n", a[n]);}return 0;}
0 0
- 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
- poj 2081【Recaman's Sequence】
- POJ 2081 Recaman's Sequence
- POJ-2081 Recaman's Sequence
- JS如何模拟鼠标点击X,Y坐标
- 模糊C均值
- scala programming 原代码
- 使用AVFoundation实现iOS原生二维码、条形码扫描(可限制扫描范围、可手动调节焦距)
- 剑指Offer-->从上向下打印二叉树(层序遍历 + 详解)
- POJ 2081 Recaman's Sequence
- untiy注意问题
- 粒子群优化算法简介
- 一般线性最小二乘法
- android 反编译和代码解读
- 本人的博客模版
- How to login as Root In ubuntu
- ACRA用法详解
- 如何判断iOS app是通过哪种途径启动的