Problem Description

As a token of his gratitude, Takahashi has decided to give his mother an integer sequence. The sequence A needs to satisfy the conditions below:

A consists of integers between X and Y (inclusive).
For each 1≤i≤|A|−1, Ai+1 is a multiple of Ai and strictly greater than Ai.
Find the maximum possible length of the sequence.

Constraints

  • 1≤XY≤1018
  • All input values are integers.

Input

Input is given from Standard Input in the following format:

X Y

Output

Print the maximum possible length of the sequence.

Example

Sample Input 1

3 20

Sample Output 1

3
The sequence 3,6,18 satisfies the conditions.

Sample Input 2

25 100

Sample Output 2

3

Sample Input 3

314159265 358979323846264338

Sample Output 3

31

题意:给出 x、y 两个数,在 x~y 范围内构造一个序列,要求第 a[i+1] 个数是第 i 个数的倍数,求序列最大的可能的长度

思路:

通过题意可知,按:x、2x、4x、8x、16x、...、2^(i-1) x 的规则构造的序列一定是最长的

因此,只要枚举 i 求出第一个大于 2^(i-1) x 的数时,i-1 就是答案

Source Program

#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<string>
#include<cstring>
#include<cmath>
#include<ctime>
#include<algorithm>
#include<utility>
#include<stack>
#include<queue>
#include<vector>
#include<set>
#include<map>
#include<bitset>
#define EPS 1e-9
#define PI acos(-1.0)
#define INF 0x3f3f3f3f
#define LL long long
const int MOD = 1E9+7;
const int N = 8000+5;
const int dx[] = {-1,1,0,0,-1,-1,1,1};
const int dy[] = {0,0,-1,1,-1,1,-1,1};
using namespace std;int main(){LL x,y;scanf("%lld%lld",&x,&y);for(LL i=0;i<100;i++){LL temp=pow(2,i-1)*x;if(temp>y){printf("%lld\n",i-1);break;}}return 0;
}

Multiple Gift(AtCoder-3731)相关推荐

  1. 寻找道路(codevs 3731)题解

    [问题描述] 在有向图 G 中,每条边的长度均为 1,现给定起点和终点,请你在图中找一条从起点到 终点的路径,该路径满足以下条件: 路径上的所有点的出边所指向的点都直接或间接与终点连通. 在满足条件 ...

  2. Codeforces Round #456 (Div. 2): E. Prime Gift(折半枚举)

    题意: 给你一个长度为n的集合,如果一个数满足它所有的质因子都在这个集合中,那么这个数就是合法的 求第k小的合法数(1<=n<=16),答案不会超过1e18 思路: 将n个数对半拆成两个集 ...

  3. [轻笔记]C++实现类自注册时出现“multiple definition”(重定义)错误

    一.背景 factory.h #pragma once #include <map> #include <iostream> #include <string> # ...

  4. CF1342D Multiple Testcases(构造题)

    题意 有 nnn 个数 {ai}\{a_i\}{ai​},每个 ai≤ka_i\leq kai​≤k . 每个背包大于等于 iii 的数的个数不能超过 ci(i=1,2,..,k)c_i(i=1,2, ...

  5. 关于前端的HTML+CSS基础知识汇总(较为全面)

    这里写目录标题 初识 空元素的两种写法 元素之间的嵌套 标准的文档结构(告诉浏览器当前使用的 HTML 标准是 html5.) 语义化 什么是语义化? 为什么需要语义化? 文本元素 h p span( ...

  6. HTTP状态码,100--505错误代码中文英文(建议收藏)

    没有用表格,因为是从各个地方复制粘贴来的. 格式是:状态码 – 英文 – 中文 1**状态码 "100" : Continue --> (继续) 请求者应当继续提出请求. 服 ...

  7. AtCoder Beginner Contest 198 (A ~ F)题解

    目录 A. Div B. Palindrome with leading zeros C. Compass Walking D. Send More Money E. Unique Color F. ...

  8. Find The Multiple POJ - 1426(只包含01的十进制倍数(同余模定理))

    Find The Multiple POJ - 1426 为了避免各位没心情看我的TLE 的过程,直接告诉你,最后两个代码是AC代码 bfs一位一位枚举,知道会爆LONG LONG 还是怀着侥幸心理试 ...

  9. R语言基于多字段(多数据列、multiple columns)对dataframe的行数据进行排序(Ordering rows)实战:使用R原生方法、data.table、dplyr等方案

    R语言基于多字段(多数据列.multiple columns)对dataframe的行数据进行排序(Ordering rows)实战:使用R原生方法.data.table.dplyr等方案 目录

最新文章

  1. Atlas Cool Application
  2. 网站搭建 (第09天) 博客统计排行
  3. C# System.Runtime.InteropServices 相关学习总结
  4. LinkedHashMap 的理解以及借助其实现LRU
  5. javaweb调用python算法_请教怎么用java远程调用python? 多谢
  6. 泛型参数怎么new_泛型编程,你不知道?(基础篇)
  7. 【ES】分布式调度系统之 Elastic-Job-Lite
  8. CentOS7安装后没网络的解决方法
  9. PHP学习总结(3)——PHP入门篇之PHP的echo语句
  10. 阿里矢量图库的正确打开方式
  11. 网络空间安全领域可投的期刊和会议
  12. 注册表怎么禁用计算机,注册表的禁用方法与解锁方法
  13. win10 ie浏览器卸载后无法重启,试了网上各种方法都无法重启
  14. pdf怎么合并在一起?
  15. 微信内域名如何防封,微信域名防封跳转
  16. 论如何科学地倒牛奶~
  17. ZKAttest: Ring and Group Signatures for existing ECDSA keys 学习笔记
  18. matlab 解目标函数,对分法求解目标函数最优解函数MATLAB实现
  19. 做电商网站如何选购云服务器?
  20. 2万字一网通办远程视频踏勘建设方案67页

热门文章

  1. 终于有人把可解释机器学习讲明白了
  2. 同宿舍程序员毕业五年后:有人年薪百万,有人月薪一万
  3. uboot烧录到SD卡
  4. 听我讲完GET、POST原理,面试官给我倒了杯卡布奇诺
  5. 上厕所时间超长也能被开除?法院:超出正常生理需求范围!
  6. 面试官:你说对MySQL事务很熟?那我问你10个问题
  7. 再有人问你volatile是什么,把这篇文章也发给他。
  8. jeecg 如何重新加载当前渲染tab页面
  9. 数据源管理 | 搜索引擎框架,ElasticSearch集群模式
  10. Mac022-brew安装tool