Codeforces 791A Bear and Big Brother(暴力枚举,模拟)
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.
分析:给你两个数字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(暴力枚举,模拟)的更多相关文章
- Codeforces 425A Sereja and Swaps(暴力枚举)
题目链接:A. Sereja and Swaps 题意:给定一个序列,能够交换k次,问交换完后的子序列最大值的最大值是多少 思路:暴力枚举每一个区间,然后每一个区间[l,r]之内的值先存在优先队列内, ...
- Codeforces Round #253 (Div. 2)B(暴力枚举)
就暴力枚举所有起点和终点就行了. 我做这题时想的太多了,最简单的暴力枚举起始点却没想到...应该先想最简单的方法,层层深入. #include<iostream> #include< ...
- Codeforces A. Bear and Big Brother
...不行.这题之后.不做1000分以下的了.很耻辱 A. Bear and Big Brother time limit per test 1 second memory limit per t ...
- codeforces 869A The Artful Expedient【暴力枚举/亦或性质】
A. time limit per test 1 second memory limit per test 256 megabytes input standard input output stan ...
- 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. ...
- Codeforces 653C Bear and Up-Down【暴力】
题目链接: http://codeforces.com/problemset/problem/653/C 题意: 给定序列,偶数位的数字比两边都大,则成为nice,只可以交换两个数字,问有多少种交换方 ...
- Codeforces Round #258 (Div. 2)C(暴力枚举)
就枚举四种情况,哪种能行就是yes了.很简单,关键是写法,我写的又丑又长...看了zhanyl的写法顿时心生敬佩.写的干净利落,简直美如画...这是功力的体现! 以下是zhanyl的写法,转载在此以供 ...
- CodeForces 550B Preparing Olympiad(DFS回溯+暴力枚举)
[题目链接]:click here~~ [题目大意] 一组题目的数目(n<=15),每一个题目有对应的难度,问你选择一定的题目(大于r个且小于l个)且选择后的题目里最小难度与最大难度差不小于x, ...
- HDU 4930 Fighting the Landlords(暴力枚举+模拟)
HDU 4930 Fighting the Landlords 题目链接 题意:就是题中那几种牌型.假设先手能一步走完.或者一步让后手无法管上,就赢 思路:先枚举出两个人全部可能的牌型的最大值.然后再 ...
随机推荐
- 【ANT】taskdef class org.programmerplanet.ant.taskdefs.jmeter.JMeterTask cannot be found using the classloader AntClassLoader[]解决办法
把文件apache-jmeter-3.1\extras\ant-jmeter-1.1.1.jar复制到apache-ant-1.10.1\lib目录下即可.
- 【ANT】使用ANT自动执行JMeter用例
1.把\apache-jmeter-3.1\extras目录下的build.xml和jmeter-results-detail-report_21.xsl两个文件拷贝到用例所在目录: 2.修改用例名称 ...
- Java之数据类型,变量赋值
Java中的基础数据类型(四类八种): 1.整数型 byte----使用byte关键字来定义byte型变量,可以一次定义多个变量并对其进行赋值,也可以不进行赋值.byte型是整型中所分配的内存空间是最 ...
- sqlserver 存储过程 查询
--查询 CREATE PROCEDURE [dbo].[SelelctMessage] @strTable varchar(), --要查询的表 @strColum varchar(), --要查询 ...
- C#创建对象时各种初始化属性、字段的方式的执行顺序
创建对象代码如下: new FilterInfo(Student.CreateTimeProperty,"朱七",Express.Equals,Relationship.Or) { ...
- IDA分析脱壳后丢失导入表的PE
1. 问题 一些程序经过脱壳后(如用OD的dump插件),一些导入表信息丢失了,导致拖入IDA后看不到API的信息(如右图所示,第一个红圈处实际是GetCurrentProcessId),给分析造成极 ...
- iView的使用【CDN向】
直接粗暴地上html代码 <!DOCTYPE html> <html> <head> <meta charset="utf-8"> ...
- ecsmart的开发经历
ecsmart是ecshop的产品之一,是2015年发布的一套系统.关于它的介绍请到官网去了解,也可以百度 “商之翼” “ecsmart” 1.ecsmart分别在pc.mobile.app三个方面都 ...
- free 命令详解
作用:显示当前系统未使用的和已使用的内存数目,还可以显示被内核使用的内存缓冲区 选项: -b 以byte为单位显示内存使用情况 -k 以kb 为单位显示内存使用情况 -m 以mb 为单位显示内存使用情 ...
- lesson - 6 课程笔记
一.df 作用: 显示磁盘分区上的可使用的磁盘空间, 默认显示单位为kb . 可以利用该命令来获取硬盘被占用了多少空间,目前还剩下多少空间的等信息. 选项: -a :包含全部的文件系统 -h :以 ...