CF791A Bear and Big Brother 【题解】
来一篇O(1)O(1)O(1)的题解
题目可以转化为求最小的xxx使得下式成立。
a∗3x>b∗2xa*3^x>b*2^xa∗3x>b∗2x
继续转化
3x2x>ba\frac{3^x}{2^x}>\frac{b}{a}2x3x>ab
即:
(32)x>ba(\frac{3}{2})^x>\frac{b}{a}(23)x>ab
那么如何求最小的xxx呢?
可以先求
(32)x=ba(\frac{3}{2})^x=\frac{b}{a}(23)x=ab
这里的xxx就是log32balog_{\frac 32}\frac balog23ab
我们只要向下取整再加上111就好啦
还有一个问题:ccc++没有log32log_{\frac 32}log23怎么办?
没关系!换底公式 , 出现!
lognm=logamloganlog_n m=\frac{log_a m}{log_a n}lognm=loganlogam
这时就可以用ccc++自带的logloglog函数啦(应该是以eee为底的)
在cmathcmathcmath库里哦!
代码奉上!
#include<iostream>
#include<cmath>
using namespace std;
int main(){int a,b;cin>>a>>b;double n=1.5,m=1.0*b/a;cout<<int(log(m)/log(n))+1;return 0;
}
CF791A Bear and Big Brother 【题解】相关推荐
- Bear and Big Brother
文章目录 一.Bear and Big Brother 总结 一.Bear and Big Brother 本题链接:Bear and Big Brother 题目: A. Bear and Big ...
- Codeforces A. Bear and Big Brother
...不行.这题之后.不做1000分以下的了.很耻辱 A. Bear and Big Brother time limit per test 1 second memory limit per tes ...
- CF - 791A. Bear and Big Brother - 模拟
1.题目描述: A. Bear and Big Brother time limit per test 1 second memory limit per test 256 megabytes inp ...
- Codeforces——791A Bear and Big Brother
小声BB 又开始更新了,最近打游戏王DL,这个栏目会留一些上分的心得. 题干 time limit per test:1 second memory limit per test:256 megaby ...
- 【codeforces 791A】Bear and Big Brother
[题目链接]:http://codeforces.com/contest/791/problem/A [题意] 给你两个数字a和b; a每次乘3,b每次乘2 问你什么时候a第一次大于b [题解] 傻逼 ...
- A. Bear and Big Brother
还是水题,上代码 #include <cstdio> #include <cstring> #include <algorithm> #include <bi ...
- Codeforces Bear and Big Brother
题目链接 题目意思 现在有两头熊,分别为熊大,熊二.他们的体重分别为a,b,其中a<=b.熊大每年体重增加三倍,熊二每年体重增加两倍.现在问过几年熊大的体重比熊二重. 解题思路 这就是一道简单的 ...
- Codeforces上通过数超过5W人的题
Codeforces上通过数超过5W人的题 共32题:1000分4题,800分28题. 编号 题号 题名 分数 通过数 1 4A Watermelon 800 x193501 2 71A Way To ...
- FZU 2151 OOXX Game
OOXX Game Problem Description Fat brother and Maze are playing a kind of special (hentai) game on an ...
最新文章
- Android Studio导入Eclipse项目的两种方法
- 深入卷积神经网络背后的数学原理
- MPO文件类型解码(四)3D图像整体结构
- 使用PowerDesigner 设计SQL Server 数据库
- redhat linux 5.6安装图解
- jdbc mysql数据库增删查改_通过JDBC对Mysql数据库进行简单的增删改查
- Android指定SDK编译版本
- Remoting示例
- selenium + java po模式
- 【大数据24小时】“天智一号”卫星将在太空计算数据;“电子身份证”亮相支付宝...
- 手机号测性别 微信男女检测原理解析 技术分享
- 联想主板9针开关接线图_空气开关、断路器、漏电保护,汇总学习一下
- 华为认证hcip怎么找工作?考取华为认证hcip证书可以做什么?
- Rasa NLU 实践
- 基于pytorch的花卉识别小程序
- 命令行连接mongo数据库
- OpenDDS3.16.1在x86/amd64平台的编译
- ubuntu 16.04/18.04安装TP-LINK TL-WDN5200H无线USB网卡驱动
- hyperledger cello 0.9.0 项目部署总结
- Win10 WSL忘记用户密码,重置密码
热门文章
- 珠海市世鸿置业有限公司投资理财实现财务自由要有复利思维
- LOL服务器维护奖励,LOL5.18版本改动内容 lol官网服务器维护公告
- 微信小程序与MCU基于阿里云MQTT协议通信
- 交通·未来第3期:基于实时WiFi-蓝牙检测数据的交通目标定位及出行模式甄别技术...
- html如何让窗口不在任务栏显示,电脑最小化窗口后无法在任务栏中显示怎么解决...
- C++ 学习方法汇总
- 百度开放平台的第三方开发步骤详解
- leveldb:Arena浅析
- go 1.20 手动内存管理arena
- ICPC2020 沈阳站 D题