Codeforces791A Bear and Big Brother
来源:互联网 发布:淘宝退换货退款流程 编辑:程序博客网 时间:2024/05/16 13:46
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.
——————————————————————————————————
题目的意思是输入两个数,第一个数每次*3,第二个数每次*2,问什么时候第一个数比第二个数大
思路:大水题
#include <iostream>#include <cstdio>#include <string>#include <cstring>#include <cmath>#include <algorithm>#include <queue>#include <vector>#include <set>#include <stack>#include <map>#include <climits>using namespace std;#define LL long longconst int INF = 0x3f3f3f3f;int main(){ int m,n; scanf("%d%d",&m,&n); int cnt=0; while(m<=n) { m*=3; n*=2; cnt++; } printf("%d\n",cnt); return 0;}
- Codeforces791A Bear and Big Brother
- A. Bear and Big Brother
- Codeforces Bear and Big Brother
- CodeForces 791A Bear and Big Brother
- Codeforces Round #405 A. Bear and Big Brother
- UESTC 1144 Big Brother
- CDOJ 1144 Big Brother
- On My Way --Brother Bear
- CDOJ 796 DAGE(Big Brother)
- Look Through my eyes --brother bear
- Great Spirits - Tina Turner --Brother Bear
- Hello Brother and Thanks, 勇哥
- Brother
- Bear and Raspberry
- codeforces Bear and Raspberry
- Bear and Raspberry
- A. Bear and Raspberry
- B. Bear and Strings
- 图书管理系统7.9(只有登录界面)
- React 数据流与状态控制-props与sate的区别
- 面试题 33: 把数组排成最小的数
- HDU
- 怎样做领导
- Codeforces791A Bear and Big Brother
- 我的第一个Vue程序
- 1124: 两个有序数组合并
- spring boot(10)-tomcat jdbc连接池
- CRC校验
- 数据库优化——使用索引
- MATLAB数据矩阵单位化,归一化,标准化
- http服务器---nginx
- SVN