日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

Multiple Gift(AtCoder-3731)

發布時間:2025/3/17 编程问答 21 豆豆
生活随笔 收集整理的這篇文章主要介紹了 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≤X≤Y≤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)的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。