2017杭电多校第七场1011Kolakoski
Kolakoski
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 524288/524288 K (Java/Others)
Total Submission(s): 0 Accepted Submission(s): 0
This sequence consists of 1 and 2,
and its first term equals 1.
Besides, if you see adjacent and equal terms as one group, you will get 1,22,11,2,1,22,1,22,11,2,11,22,1…….
Count number of terms in every group, you will get the sequence itself. Now, the sequence can be uniquely determined. Please tell HazelFan its nth
element.
denoting the number of test cases.
For each test case:
A single line contains a positive integer n(1≤n≤107).
A single line contains a nonnegative integer, denoting the answer.
1
2
2
Statistic | Submit | Clarifications | Back
#include <cstdio>
#include <iostream>
#include <cstring>
#include <queue>
#include <algorithm>
using namespace std;
const int maxn = 1e7 + 100;
int table[maxn] = { 0,1,2,2,1,1,2,1,2,2,1,2,2,1,1,2,1,1,2,2,1 };
int table1[maxn] = { 0,1 };
long long int ti = 2;
int tem = 1;
void init() {
for (int i = 2; ti < maxn-50; ++i) {
tem = tem % 2 + 1;
if (table[i] == 2) {
table1[ti] = tem;
table[ti++] = tem;
table1[ti] = tem;
table[ti++] = tem;
}
else {
table1[ti] = tem;
table[ti++] = tem;
}
}
}
int main()
{
init();
int t;
cin >> t;
long long int n;
while (t--)
{
cin >> n;
cout << table1[n] << endl;
}
return 0;
}
2017杭电多校第七场1011Kolakoski的更多相关文章
- 2017杭电多校第七场1005Euler theorem
Euler theorem Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 524288/524288 K (Java/Others) ...
- 2017杭电多校第六场1008 Kirinriki
传送门 Kirinriki Time Limit: 4000/2000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others) To ...
- 2017杭电多校第五场11Rikka with Competition
Rikka with Competition Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/O ...
- 2017杭电多校第五场Rikka with Subset
Rikka with Subset Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others ...
- 杭电多校第七场 1010 Sequence(除法分块+矩阵快速幂)
Sequence Problem Description Let us define a sequence as below f1=A f2=B fn=C*fn-2+D*fn-1+[p/n] Your ...
- 杭电多校第七场-J-Sequence
题目描述 Let us define a sequence as belowYour job is simple, for each task, you should output Fn module ...
- 2017杭电多校第六场1011Classes
传送门 Classes Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others) Tota ...
- 2017杭电多校第六场03Inversion
传送门 Inversion Time Limit: 4000/2000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others) To ...
- hdu61272017杭电多校第七场1008Hard challenge
Hard challenge Time Limit: 4000/2000 MS (Java/Others) Memory Limit: 524288/524288 K (Java/Others) ...
随机推荐
- zoj4710暴力
#include<stdio.h> #include<string.h> #define N 110 int map[N][N]; int main() { int n,m,k ...
- 前端开发:HTML
静态页面: 没有与用户进行交互,而仅仅是用户浏览的一个网页 动态网页:就是用户不仅仅可以浏览网页,还可以与服务器交互 Web前端应用场景:公司官网(在PC通过浏览器访问公司网站).移动端网页(在手机上 ...
- POJ1422 Air Raid
Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 8006 Accepted: 4803 Description Consi ...
- POJ 3734_Blocks
题意: 用红绿蓝黄四种颜色对一序列n个方块涂色,求出绿和红色方块数同时为偶数的染色方案数.mod=10007 分析: dp+矩阵快速幂 首先明确有三种状态: 红和绿均为偶数 红和绿只有一个为奇数 红和 ...
- P2910 [USACO08OPEN]寻宝之路Clear And Present Danger 洛谷
https://www.luogu.org/problem/show?pid=2910 题目描述 Farmer John is on a boat seeking fabled treasure on ...
- Codeforces Educational Round 21
A =w= B qwq C wvw D(multiset) 题意: 有n(n<=1e5)个数,希望通过把一个位置y的数字放到位置x上这个操作,使得新序列的某个前缀和等于总和的一半,问这样的操作是 ...
- 【编程大系】Java资源汇总
1.学习资料: 1)Spring Boot 那些事:https://www.w3cschool.cn/springboot/ 对应的 gitHub代码: https://github.com/Jeff ...
- u启动为苹果笔记本重装win7系统教程
准备更换系统的苹果笔记本一台! 上述需要准备的东西均准备好以后我们就开始今天的教程了!! 首先,将已经制作好启动盘的u启动u盘插入到苹果笔记本上的usb插口,然后开机! 由于苹果笔记本电脑 ...
- 文本分类——NaiveBayes
前面文章已经介绍了朴素贝叶斯算法的原理,这里基于NavieBayes算法对newsgroup文本进行分类測试. 文中代码參考:http://blog.csdn.net/jiangliqing1234/ ...
- Cocos2d-X中的ProgressTimer
ProgressTimer即进度条,进度条在游戏开发中运用很广泛,比如在一些格斗游戏中,显示血液的变化,还有游戏载入进度,等都离不开进度条 Cocos2d-X中使用CCProgressTimer ...