Multiple Gift(AtCoder-3731)

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;
}

 

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
"no-multiple-template-root"是一个eslint规则,用于检查Vue模板中是否只有一个根元素。如果在Vue项目中引入了这个规则,并且在模板中使用了多个根元素的话,就会报错。 解决这个问题的方法是在项目的.eslintrc.js配置文件的rules中添加规则"vue/no-multiple-template-root": "off",将其关闭。这样就可以在模板中使用多个根元素而不会报错了。 需要注意的是,在Vue3.0中允许在<template>标签下使用多个根元素,但在早期版本中是不被允许的。如果你使用的是Vue3.0及以上版本,你可以忽略这个eslint规则,因为它已经被修复了。<span class="em">1</span><span class="em">2</span><span class="em">3</span> #### 引用[.reference_title] - *1* *3* [vue3代码报错:[vue/no-multiple-template-root]The template root requires exactly one element.eslint-...](https://blog.csdn.net/weixin_51938803/article/details/131067295)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_2"}}] [.reference_item style="max-width: 50%"] - *2* [vue3报错:The template root requires exactly one element终极解决办法](https://blog.csdn.net/Y_soybean_milk/article/details/124338835)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_2"}}] [.reference_item style="max-width: 50%"] [ .reference_list ]
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值