题意:由1,2,2,1,1,2,1,2,2,1,2,2,1,1,2,1,1,2,2,1,……合并可得1,22,11,2,1,22,1,22,11,2,11,22,1,再由每个数的位数可得新序列,推出新序列第n项。

分析:新序列与原序列相同,按题意打表即可。

#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<cctype>
#include<cmath>
#include<iostream>
#include<sstream>
#include<iterator>
#include<algorithm>
#include<string>
#include<vector>
#include<set>
#include<map>
#include<stack>
#include<deque>
#include<queue>
#include<list>
#define lowbit(x) (x & (-x))
const double eps = 1e-8;
inline int dcmp(double a, double b){
if(fabs(a - b) < eps) return 0;
return a > b ? 1 : -1;
}
typedef long long LL;
typedef unsigned long long ULL;
const int INT_INF = 0x3f3f3f3f;
const int INT_M_INF = 0x7f7f7f7f;
const LL LL_INF = 0x3f3f3f3f3f3f3f3f;
const LL LL_M_INF = 0x7f7f7f7f7f7f7f7f;
const int dr[] = {0, 0, -1, 1, -1, -1, 1, 1};
const int dc[] = {-1, 1, 0, 0, -1, 1, -1, 1};
const int MOD = 1e9 + 7;
const double pi = acos(-1.0);
const int MAXN = 10000 + 10;
const int MAXT = 10000 + 10;
using namespace std;
vector<int> v;
int main(){
v.push_back(1);
v.push_back(2);
v.push_back(2);
v.push_back(1);
v.push_back(1);
int cur = 3;
while(1){
int cnt = v[cur];
int x;
if(v.size() & 1){
x = 2;
}
else{
x = 1;
}
for(int i = 0; i < cnt; ++i){
v.push_back(x);
}
if(v.size() > 10000000) break;
}
int T;
scanf("%d", &T);
while(T--){
int n;
scanf("%d", &n);
printf("%d\n", v[n - 1]);
}
return 0;
}

 

HDU - 6130 Kolakoski (打表)的更多相关文章

  1. HDU 6130 Kolakoski

    Kolakoski 思路: 从前往后扩展,前后构成映射关系. 代码: #include<bits/stdc++.h> using namespace std; #define ll lon ...

  2. hdu 1496 Equations hash表

    hdu 1496 Equations hash表 题目链接 http://acm.hdu.edu.cn/showproblem.php?pid=1496 思路: hash表,将原来\(n^{4}\)降 ...

  3. hdu 5104 素数打表水题

    http://acm.hdu.edu.cn/showproblem.php?pid=5104 找元组数量,满足p1<=p2<=p3且p1+p2+p3=n且都是素数 不用素数打表都能过,数据 ...

  4. HDU 5976 Detachment 打表找规律

    题目链接: http://acm.hdu.edu.cn/showproblem.php?pid=5976 Detachment Time Limit: 4000/2000 MS (Java/Other ...

  5. Hdu 5289-Assignment 贪心,ST表

    题目: http://acm.hdu.edu.cn/showproblem.php?pid=5289 Assignment Time Limit: 4000/2000 MS (Java/Others) ...

  6. hdu 6253 (bfs打表)

    链接:http://acm.hdu.edu.cn/showproblem.php?pid=6253 题意: 马可以往一个方向走两步,然后转个弯走一步,这样算一次动作,求问马n次动作后,能到达多少个点, ...

  7. HDU 3032 multi-sg 打表找规律

    普通NIM规则加上一条可以分解为两堆,标准的Multi-SG游戏 一般Multi-SG就是根据拓扑图计算SG函数,这题打表后还能发现规律 sg(1)=1 sg(2)=2 sg(3)=mex{0,1,2 ...

  8. HDU 4707 Pet 邻接表实现

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4707 解题报告:题目大意是在无向图G中有n个点,分别从0 到n-1编号,然后在这些点之间有n-1条边, ...

  9. HDU 2136 素数打表+求质数因子

    Largest prime factor Time Limit: 5000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Oth ...

随机推荐

  1. Thymeleaf的内置属性(转)

    原文链接: http://somefuture.iteye.com/blog/2253761 Thymeleaf是另一个Java视图模板引擎,使用上和FreeMarker各有千秋,不了解的可以从其他博 ...

  2. VS2013 ERROR MSB8020

    error MSB8020: The build tools for Visual Studio 2013 (Platform Toolset = 'v120') cannot be found. T ...

  3. SQL数据库入门基础

      SQL(Structure Query Language,结构化查询语言)语言是国际标准化组织(ISO)采纳的标准数据库语言. 数据库就是一幢大楼,我们要先盖楼,然后再招住户(住户当然就是数据库对 ...

  4. list.Except()

    差集 List<string> list = new List<string>() { ", ", ", }; List<string> ...

  5. oracle中 lob类型

    LOB大型对象(大数据字段类型) 分为:-BLOB: Binary 二进制大型对象 ,适用于存非文本型数据(程序,图像,影音) -CLOB:Character  字符型大型对象,适用于存储文本型数据( ...

  6. 5G风口之下,NFV为何发展迅速

    导读 5G高带宽.低时延.大容量的接入方式,注定它一定要依赖于跟以往完全不同的专业设备模式来实现,因此也创造了更多的方向和机会.NFV就是其中之一. 5G最大的变化在网络层面,需要底层网络架构形成一种 ...

  7. Linux CentOS7 VMware 特殊权限set_uid、特殊权限set_gid、特殊权限stick_bit、软链接文件、硬连接文件

    一.特殊权限set_uid root用户本身拥有对/etc/passwd的写权限,无可厚非:那普通用户呢,这里就用到了setuid,setuid的作用是“让执行该命令的用户以该命令拥有者的权限去执行” ...

  8. git+jenkins jar包代码的发布加新建项目

    1.本地仓库  java开发 把代码上传上来 ,问一下他要上传到的主机ip , 分支 2.本地 , 设置-->仓库 更新数据,让他同步到南阳gitlab, 若没有这个项目,需要创建相同名字的项目 ...

  9. git客户端出现libpng warning: iCCP: known incorrect sRGB profile

    在关闭gitk窗口的时候,会出现一系列的  libpng warning: iCCP: known incorrect sRGB profilelibpng warning: iCCP: known  ...

  10. TeX 常用命令记录

    常用: $a_{i}^{2}$    a_{i}^{2} $\sqrt x$     $\sqrt[n] x$     \sqrt[n] x $\frac{1+2}{3+4}$ 重音符号: $\hat ...