Codeforces A. Bear and Big Brother
1 second
256 megabytes
standard input
standard output
Bear Limak wants to become the largest of bears, or at least to become larger than his brother Bob.
Right now, Limak and Bob weigh a and b respectively. It's guaranteed that Limak's weight is smaller than or equal to his brother's weight.
Limak eats a lot and his weight is tripled after every year, while Bob's weight is doubled after every year.
After how many full years will Limak become strictly larger (strictly heavier) than Bob?
The only line of the input contains two integers a and b (1 ≤ a ≤ b ≤ 10) — the weight of Limak and the weight of Bob respectively.
Print one integer, denoting the integer number of years after which Limak will become strictly larger than Bob.
4 7
2
4 9
3
1 1
1
In the first sample, Limak weighs 4 and Bob weighs 7 initially. After one year their weights are 4·3 = 12 and 7·2 = 14 respectively (one weight is tripled while the other one is doubled). Limak isn't larger than Bob yet. After the second year weights are 36 and 28, so the first weight is greater than the second one. Limak became larger than Bob after two years so you should print 2.
In the second sample, Limak's and Bob's weights in next years are: 12 and 18, then 36 and 36, and finally 108 and 72 (after three years). The answer is 3. Remember that Limak wants to be larger than Bob and he won't be satisfied with equal weights.
In the third sample, Limak becomes larger than Bob after the first year. Their weights will be 3 and 2 then.
#include<iostream>
using namespace std;
int main(){
int a;
int b;
cin>>a;
cin>>b;
int res = ;
do{
res++;
a*=;
b*=;
}while(a<=b);
cout<<res;
return ;
}
最新文章
- css3 text-overflow和white-space,word-wrap,word-break进阶
- Django admin coercing to Unicode: need string or buffer, tuple found
- POJ 1741 Tree 树分治
- 像jQuery那样,采用链式方法,封装一个方法:CSS()
- CentOS 7 网络配置方法
- 数值的整数次方(剑指offer面试题11)
- java学习之创建线程方法二
- Python之路【第五篇】:面向对象和相关
- 文本溢出、垂直外边距合并、BFC、hasLayout
- 概率图模型(PGM)学习笔记(四)-贝叶斯网络-伯努利贝叶斯-多项式贝叶斯
- 微软MVP社区夏日巡讲诚邀您的参与: 北京,上海,西宁,成都,西安
- 使用Visual Studio 2010写Data Url生成工具C#版本
- ASP.NET中ListBox控件的使用
- css grid布局的首次使用
- ASP.NET Core WebApi 返回统一格式参数(Json 中 Null 替换为空字符串)
- IOC 的理解与解释
- (四)五种IO模型
- UITableView(自定义cell)试水心得
- nullpointerxception——处理思路
- Debian 8 安装录屏软件kazam