CSU-2108: Incomplete Book

2108: Incomplete Book

Submit Page      Summary      Time Limit: 1 Sec       Memory Limit: 128 Mb       Submitted: 54       Solved: 34    

Description

Meorge Arr Arr Gartin, the pirate, is currently writing a series of amazing novels. Full of inspiration, his first novel only took him k days to write. However, as time went on, he started writing slower and slower. In particular, if it took him L days to write the ith book in the series, then it will take him 2L days to write the (i + 1)th book. Because of how slow he is writing the series, fans are worried that he will not be around long enough to finish the series before he dies. What is the maximum number of books that he can finish before he dies?

Input

The input consists of a single line containing two integers k (1 ≤ k ≤ 365), which is the number of days needed to write the first book, and d (k ≤ d ≤ 109), which is the number of days after he started writing the first book that he will die.

Output

Display the maximum number of books that he can finish.

Sample Input

1 1

1 2

1 3

117 1337

Sample Output

1

1

2

3

Hint

Source

South Pacific Divisionals

题意:某人完成一篇文章需要k天,第i篇文章时间是第i - 1篇文章时间的两倍,给定第一篇文章的时间和剩余生命时间,问能完成几篇文章!

题解:水题,随便写啦~

AC代码

#include <iostream>
#include <string>
#include <string.h>
#include <vector>
#include <map>
#include <queue>
#include <algorithm>
typedef long long ll;

using namespace std;

int main(){
	ll k, d;
	while(scanf("%lld %lld", &k, &d) != EOF){
		ll ans = 0;
		while(d >= k){
			ans++;
			d -= k;
			k = k * 2;
		}
		printf("%lld\n", ans);
	}
    return 0;
}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值