Codeforces Round #384 (Div. 2)B. Chloe and the sequence 数学
B. Chloe and the sequence
题目链接
http://codeforces.com/contest/743/problem/B
题面
Chloe, the same as Vladik, is a competitive programmer. She didn't have any problems to get to the olympiad like Vladik, but she was confused by the task proposed on the olympiad.
Let's consider the following algorithm of generating a sequence of integers. Initially we have a sequence consisting of a single element equal to 1. Then we perform (n - 1) steps. On each step we take the sequence we've got on the previous step, append it to the end of itself and insert in the middle the minimum positive integer we haven't used before. For example, we get the sequence [1, 2, 1] after the first step, the sequence [1, 2, 1, 3, 1, 2, 1] after the second step.
The task is to find the value of the element with index k (the elements are numbered from 1) in the obtained sequence, i. e. after (n - 1) steps.
Please help Chloe to solve the problem!
输入
The only line contains two integers n and k (1 ≤ n ≤ 50, 1 ≤ k ≤ 2n - 1).
输出
Print single integer — the integer at the k-th position in the obtained sequence.
样例输入
3 2
样例输出
2
题意
假设现在的数列是a,那么在a的背后放一个最小的没出现过的整数,然后再把a重复的放在后面。
然后现在问你p位置是什么
题解
直接按照题意模拟迭代下去也可以……
但实际上就是这个p数字的二进制最小的1的位数的位置。
代码
#include<bits/stdc++.h>
using namespace std;
long long n,p;
int main()
{
scanf("%lld%lld",&n,&p);
cout<<log2(p&(-p))+1<<endl;
}
Codeforces Round #384 (Div. 2)B. Chloe and the sequence 数学的更多相关文章
- Codeforces Round #384 (Div. 2) B. Chloe and the sequence(规律题)
传送门 Description Chloe, the same as Vladik, is a competitive programmer. She didn't have any problems ...
- Codeforces Round #384 (Div. 2)D - Chloe and pleasant prizes 树形dp
D - Chloe and pleasant prizes 链接 http://codeforces.com/contest/743/problem/D 题面 Generous sponsors of ...
- Codeforces Round #529 (Div. 3) E. Almost Regular Bracket Sequence (思维)
Codeforces Round #529 (Div. 3) 题目传送门 题意: 给你由左右括号组成的字符串,问你有多少处括号翻转过来是合法的序列 思路: 这么考虑: 如果是左括号 1)整个序列左括号 ...
- Codeforces Round #384 (Div. 2) //复习状压... 罚时爆炸 BOOM _DONE
不想欠题了..... 多打打CF才知道自己智商不足啊... A. Vladik and flights 给你一个01串 相同之间随便飞 没有费用 不同的飞需要费用为 abs i-j 真是题意杀啊, ...
- Codeforces Round #384 (Div. 2)A,B,C,D
A. Vladik and flights time limit per test 2 seconds memory limit per test 256 megabytes input standa ...
- Codeforces Round #384 (Div. 2) A B C D dfs序+求两个不相交区间 最大权值和
A. Vladik and flights time limit per test 2 seconds memory limit per test 256 megabytes input standa ...
- Codeforces Round #384 (Div. 2) C. Vladik and fractions 构造题
C. Vladik and fractions 题目链接 http://codeforces.com/contest/743/problem/C 题面 Vladik and Chloe decided ...
- Codeforces Round #384 (Div. 2) C. Vladik and fractions(构造题)
传送门 Description Vladik and Chloe decided to determine who of them is better at math. Vladik claimed ...
- Codeforces Round #384 (Div. 2)D-Chloe and pleasant prizes
D. Chloe and pleasant prizes time limit per test 2 seconds memory limit per test 256 megabytes input ...
随机推荐
- TYVJ计算几何
今天讲了计算几何,发几道水水的tyvj上的题解... 计算几何好难啊!@Mrs.General....怎么办.... 这几道题都是在省选之前做的,所以前面的Point运算啊,dcmp啊,什么什么的,基 ...
- 使用wxPython WebView浏览器版本问题
使用CodeMirror和wxPyhton的WebView创建嵌入客户端的本地代码编辑工具. 版本为wxPython 3.0,CodeMirror 支持的浏览器IE8或以上. wxPython提供了H ...
- Titanium系列--我常用的Titanium的快捷键(持续更新中。。)
Titanium快捷键: (注:Titanium属于eclipse系列的IDE) ctrl + shift + r 快速打开 ctrl + shift + e / ctrl + e 打开之前的文件 c ...
- 关于 pgsql 数据库json几个函数用法的效率测试
关于 pgsql 数据库json几个函数用法的效率测试 关于pgsql 几个操作符的效率测试比较1. json::->> 和 ->> 测试方法:单次运行100次,运行10个单次 ...
- mysqld: Incorrect key file for table
错误 140624 0:53:42 [ERROR] /usr/libexec/mysqld: Incorrect key file for table './xx/xxx.MYI'; try to r ...
- Apache Mina(一)
原文链接:http://www.cnblogs.com/xuekyo/archive/2013/03/06/2945826.html Apache Mina是一个能够帮助用户开发高性能和高伸缩性网络应 ...
- C语言 队列 顺序结构 实现
一个能够自动扩容的顺序结构的队列 ArrQueue (GCC编译). /** * @brief C语言顺序结构队列的实现 * @author wid * @date 2013-10-30 * * @n ...
- NodeJS package.json
#3 NodeJS package.json 工作目录 package.json 导航至工作目录后,执行下图中的命令
- Mac 快捷键整理
Mac 快捷键整理 文本编辑 适用于文本编辑器,浏览器等 跳到页首 cmd + ↑ 类似windows下的 ctrl + home 跳到页尾 cmd + ↓ 类似windows下的 ctrl + en ...
- python os&shutil 文件操作
python os&shutil 文件操作 # os 模块 os.sep 可以取代操作系统特定的路径分隔符.windows下为 '\\' os.name 字符串指示你正在使用的平台.比如对于W ...