HDU 6130 Kolakoski
思路:
从前往后扩展,前后构成映射关系。
代码:
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define mem(a,b) memset((a),(b),sizeof(a))
const int N=1e7+;
int dp[N]={,,,}; int main()
{
ios::sync_with_stdio(false);
cin.tie();
int t=;
int i=,j=; while(j<N)
{
for(int k=;k<dp[i];k++)
{
dp[j++]=t;
}
if(t==)t=;
else t=;
i++;
} cin>>t;
int n;
while(t--)
{
cin>>n;
cout<<dp[n-]<<endl;
}
return ;
}
HDU 6130 Kolakoski的更多相关文章
- HDU - 6130 Kolakoski (打表)
题意:由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,再由每个数的位数可得新序列,推出新 ...
- HDU 3130 17多校7 Kolakoski(思维简单)
Problem Description This is Kolakosiki sequence: 1,2,2,1,1,2,1,2,2,1,2,2,1,1,2,1,1,2,2,1……. This seq ...
- 【2017 Multi-University Training Contest - Team 7】Kolakoski
[Link]:http://acm.hdu.edu.cn/contests/contest_showproblem.php?pid=1011&cid=765 [Description] 有一种 ...
- HDOJ 2111. Saving HDU 贪心 结构体排序
Saving HDU Time Limit: 3000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) Total ...
- 【HDU 3037】Saving Beans Lucas定理模板
http://acm.hdu.edu.cn/showproblem.php?pid=3037 Lucas定理模板. 现在才写,noip滚粗前兆QAQ #include<cstdio> #i ...
- hdu 4859 海岸线 Bestcoder Round 1
http://acm.hdu.edu.cn/showproblem.php?pid=4859 题目大意: 在一个矩形周围都是海,这个矩形中有陆地,深海和浅海.浅海是可以填成陆地的. 求最多有多少条方格 ...
- HDU 4569 Special equations(取模)
Special equations Time Limit:1000MS Memory Limit:32768KB 64bit IO Format:%I64d & %I64u S ...
- HDU 4006The kth great number(K大数 +小顶堆)
The kth great number Time Limit:1000MS Memory Limit:65768KB 64bit IO Format:%I64d & %I64 ...
- HDU 1796How many integers can you find(容斥原理)
How many integers can you find Time Limit:5000MS Memory Limit:32768KB 64bit IO Format:%I64d ...
随机推荐
- 表单验证——JqueryValidator、BootstrapValidator
表单验证两种方式: 1.JqueryValidator <!DOCTYPE html> <html lang="en"> <head> < ...
- EditPlus 4.3.2555 中文版已经发布
新的版本修复了之前版本出现的多行文本缩进调整的问题. 下载连接在页面左上角!
- python excel练习:新建sheet、修改名称、设定颜色、打印sheet名称,复制,保存
练习: 新建一个sheet 设定一个sheet的插入位置 修改sheet的名称为‘xiaxiaoxu’ 设定该sheet的背景标签的颜色 获取全部sheet的名称,打印每个sheet的名称 copy一 ...
- ui-grid angularjs
<pre name="code" class="html"><!--ui-grid css--> <link rel=" ...
- pyDay2
内容来自廖雪峰的官方网站 1.dict 为什么dict查找速度这么快?因为dict的实现原理和查字典是一样的.假设字典包含了1万个汉字,我们要查某一个字,一个办法是把字典从第一页往后翻,直到找到我们想 ...
- MySQL新建用户保存的时报错:The MySQL server is running with the --skip-grant-tables option so it cannot execute this statement
又是这种错, 以前没遇过, 没办法, 直接google. 下面看解决办法: 登录mysql, 当然了如果您登录不上(密码错误情况), 直接扔这个属性进去my.cnf配置文件skip-grant-tab ...
- 维特比算法Python实现
前言 维特比算法是隐马尔科夫问题的一个基本问题算法.维特比算法解决的问题是已知观察序列,求最可能的标注序列. 什么是维特比算法? 维特比算法尽管是基于严格的数学模型的算法,但是维特比算法毕竟是算法,因 ...
- trust zone之我见【转】
本文转载自:https://blog.csdn.net/hovan/article/details/42520879 老板交待任务,这个星期我都在研究trust zone的东东,之前有看过代码,但没有 ...
- git的软件安装
1.Git for Winodws 1.*的版本 https://github.com/msysgit/msysgit/releases 2.*的版本 https://github.com/g ...
- BZOJ3297: [USACO2011 Open]forgot DP+字符串
Description 发生了这么多,贝茜已经忘记了她cowtube密码.然而,她记得一些有用的信息.首先,她记得她的密码(记为变 量P)长度为L(1 <= L<=1,000)字符串,并可 ...