A. Bear and Big Brother
time limit per test:1 second
memory limit per test:256 megabytes
input:standard input
output: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?

Input

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.

Output

Print one integer, denoting the integer number of years after which Limak will become strictly larger than Bob.

Examples
Input
4 7
Output
2
Input
4 9
Output
3
Input
1 1
Output
1
Note

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.

分析:给你两个数字a和b; a每次乘3,b每次乘2,问你什么时候a第一次大于b!

题目链接:http://codeforces.com/contest/791/problem/A

下面给出AC代码:

 #include <bits/stdc++.h>
using namespace std;
int main()
{
int a,b,i;
int c,d;
while(scanf("%d%d",&a,&b)!=EOF)
{
int ans=;
if(a-b>)
printf("0\n");
else if(a-b==)
printf("1\n");
while(a-b<)
{
ans++;
a*=;
b*=;
if(a-b>)
{
printf("%d\n",ans);
break;
}
else if(a-b==)
{
printf("%d\n",ans+);
break;
}
}
}
return ;
}

Codeforces 791A Bear and Big Brother(暴力枚举,模拟)的更多相关文章

  1. Codeforces 425A Sereja and Swaps(暴力枚举)

    题目链接:A. Sereja and Swaps 题意:给定一个序列,能够交换k次,问交换完后的子序列最大值的最大值是多少 思路:暴力枚举每一个区间,然后每一个区间[l,r]之内的值先存在优先队列内, ...

  2. Codeforces Round #253 (Div. 2)B(暴力枚举)

    就暴力枚举所有起点和终点就行了. 我做这题时想的太多了,最简单的暴力枚举起始点却没想到...应该先想最简单的方法,层层深入. #include<iostream> #include< ...

  3. Codeforces A. Bear and Big Brother

    ...不行.这题之后.不做1000分以下的了.很耻辱   A. Bear and Big Brother time limit per test 1 second memory limit per t ...

  4. codeforces 869A The Artful Expedient【暴力枚举/亦或性质】

    A. time limit per test 1 second memory limit per test 256 megabytes input standard input output stan ...

  5. Codeforce 791A - Bear and Big Brother

    Bear Limak wants to become the largest of bears, or at least to become larger than his brother Bob. ...

  6. Codeforces 653C Bear and Up-Down【暴力】

    题目链接: http://codeforces.com/problemset/problem/653/C 题意: 给定序列,偶数位的数字比两边都大,则成为nice,只可以交换两个数字,问有多少种交换方 ...

  7. Codeforces Round #258 (Div. 2)C(暴力枚举)

    就枚举四种情况,哪种能行就是yes了.很简单,关键是写法,我写的又丑又长...看了zhanyl的写法顿时心生敬佩.写的干净利落,简直美如画...这是功力的体现! 以下是zhanyl的写法,转载在此以供 ...

  8. CodeForces 550B Preparing Olympiad(DFS回溯+暴力枚举)

    [题目链接]:click here~~ [题目大意] 一组题目的数目(n<=15),每一个题目有对应的难度,问你选择一定的题目(大于r个且小于l个)且选择后的题目里最小难度与最大难度差不小于x, ...

  9. HDU 4930 Fighting the Landlords(暴力枚举+模拟)

    HDU 4930 Fighting the Landlords 题目链接 题意:就是题中那几种牌型.假设先手能一步走完.或者一步让后手无法管上,就赢 思路:先枚举出两个人全部可能的牌型的最大值.然后再 ...

随机推荐

  1. 串String(1):串的实现(定长顺序存储结构)

    前言 PS:本文相关头文件.预编译以及typedef如下,阅读一遍以便于下面的理解: #include <stdio.h> #include <stdlib.h> #inclu ...

  2. 并行cmd

    #!/bin/bash ]; then echo -e "usage : \n\t$0 hostList REMOTE_CMD" echo -e "example: \n ...

  3. Mysql 备份恢复与xtrabackup备份

  4. postgresql 导出函数的方法

    先放一条mysql的导出语句 /usr/bin/mysqldump -h127.30.100.33 -P3388 -uname -ppassword --databases databasename ...

  5. 使用 PyCharm 添加 第三方 依赖库

    背景 最近开始搞python, 需要帮助算法同事一起调试程序,在本地安装python以后使用 pip 来安装第三方库. 但是算法同事一直使用的是PyCharm 这个IDE,所以需要与他一起调试的时候也 ...

  6. (通用)深度学习环境搭建:tensorflow安装教程及常见错误解决

    区别于其他入门教程的"手把手式",本文更强调"因"而非"果".我之所以加上"通用"字样,是因为在你了解了这个开发环境之后 ...

  7. Java的演化-Java8实战笔记

    一个语言要想一直有活力,它也需要跟随着时代的变化去进步,Java作为一个古老的语言,它其实有太多的历史包袱,在改变的过程中需要考虑很多,但是它也在慢慢的演变,巩固自己的城墙,不让自己被遗忘在历史中(不 ...

  8. js 错误Error对象详解

    一.概念 error,指程序中的非正常运行状态,在其他编程语言中称为"异常"或"错误".解释器会为每个错误情形创建并抛出一个Error对象,其中包含错误的描述信 ...

  9. hadoop+hive+spark搭建(二)

    上传hive软件包到任意节点 一.安装hive软件 解压缩hive软件包到/usr/local/hadoop/目录下 重命名hive文件夹 在/etc/profile文件中添加环境变量 export ...

  10. (译)Web是如何工作的(3):HTTP&REST

    原文地址:https://medium.freecodecamp.org/how-the-web-works-part-iii-http-rest-e61bc50fa0a   我们在第一篇文章中介绍了 ...