CF987B - High School: Become Human
Year 2118. Androids are in mass production for decades now, and they do all the work for humans. But androids have to go to school to be able to solve creative tasks. Just like humans before.
It turns out that high school struggles are not gone. If someone is not like others, he is bullied. Vasya-8800 is an economy-class android which is produced by a little-known company. His design is not perfect, his characteristics also could be better. So he is bullied by other androids.
One of the popular pranks on Vasya is to force him to compare xy with yx. Other androids can do it in milliseconds while Vasya's memory is too small to store such big numbers.
Please help Vasya! Write a fast program to compare xyxy with yx for Vasya, maybe then other androids will respect him.
Input
On the only line of input there are two integers x and y (1≤x,y≤109).
Output
If xy<yx, then print '<' (without quotes). If xy>yx, then print '>' (without quotes). If xy=yx, then print '=' (without quotes).
Examples
5 8
>
10 3
<
6 6
=
Note
In the first example 5 8=5⋅5⋅5⋅5⋅5⋅5⋅5⋅5=390625, and 85=8⋅8⋅8⋅8⋅8=32768. So you should print '>'.
In the second example 10 3=1000<3 10=59049.
In the third example 6 6=46656=6 6.
这道题,看题意首先想到快速幂,再看数据范围,显然会炸,那么最简单粗暴的方法就是,比较 x ^ y 与 y ^ x 的大小关系。(如此简洁明了的题面 >_<)
我们要先在两式旁取对数,就是比较 ln x ^ y 与 ln y ^ x 的大小关系,先假设左式小于右式:(前方高能,请注意)
ln x ^ y < ln y & x; 即 y * ln x < x * lny;
所以 ln x / x < ln y / y;
那么通过归纳我们可以设 f (n) = ln n / n;
取这个函数的导数,即 f'(n) = ( ln n - 1 )/ n ^ 2;
那么当 f'(n)> 0 时, ln n > 1, 所以当 x, y > e (因为是整数,相当于大于等于3)时, 若 x > y, 则 x ^ y < y ^ x;
证明完成之后,我们就可以知道,当给出的 x , y 大于 3 的时候,只需要判断 x 和 y 的大小关系即可,其他的只要特判就可以了
#include<bits/stdc++.h>
using namespace std;
int main()
{
int x,y,i;
cin>>x>>y;
if(x == y){
cout<<"="<<endl;
return 0;
}
else{
if(x == 1){
cout<<"<";
return 0;
}
if(y == 1){
cout<<">";
return 0;
}
int h = max(x,y);
if(h <= 4){
long long sum1 = 1,sum2 = 1;
for(i = 1; i <= y; i++){
sum1 *= x;
}
for(i = 1; i <= x; i++){
sum2 *= y;
}
if(sum1 < sum2){
cout<<"<";
}
else if(sum1 > sum2){
cout<<">";
}
else{
cout<<"=";
}
}
else{
if(x > y){
cout<<"<";
}
else{
cout<<">";
}
}
}
return 0;
}
CF987B - High School: Become Human的更多相关文章
- CF987B High School: Become Human 数学
题意翻译 题目大意 输入一个 xxx ,一个 yyy ,求是 xyx^yxy 大还是 yxy^xyx 大. (1≤x,y≤109)(1≤x,y≤10^9)(1≤x,y≤109) 输入输出格式 输入格式 ...
- Human and AI's future (reverie)
However, I do notice that to make the dark situation happen, it doesn't require the topleft matrix t ...
- Human Gene Functions
Human Gene Functions Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 18053 Accepted: 1004 ...
- PacBio & BioNano (Assembly and diploid architecture of an individual human genome via single-molecule technologies)
Assembly and diploid architecture of an individual human genome via single-molecule technologies 文章链 ...
- POJ 1080 Human Gene Functions -- 动态规划(最长公共子序列)
题目地址:http://poj.org/problem?id=1080 Description It is well known that a human gene can be considered ...
- APP-PER-50022: Oracle Human Resources could not retrieve a value for the User Type profile option.
Symptoms ----------------------- AP > Setup > Organizations Show Error tips: APP-PER-50022: Or ...
- Unity3d 屏幕空间人体皮肤知觉渲染&次表面散射Screen-Space Perceptual Rendering & Subsurface Scattering of Human Skin
之前的人皮渲染相关 前篇1:unity3d Human skin real time rendering 真实模拟人皮实时渲染 前篇2:unity3d Human skin real time ren ...
- 【译】iOS人性化界面指南(iOS Human Interface Guidelines)(一)
1. 引言1.1 译者自述 我是一个表达能力一般的开发员,不管是书面表达,还是语言表达.在很早以前其实就有通过写博客锻炼这方面能力的想法,但水平有限实在没有什么拿得出手的东西分享.自2015年7月以来 ...
- [文学阅读] METEOR: An Automatic Metric for MT Evaluation with Improved Correlation with Human Judgments
METEOR: An Automatic Metric for MT Evaluation with Improved Correlation with Human Judgments Satanje ...
随机推荐
- KFold,StratifiedKFold k折交叉切分
python风控评分卡建模和风控常识(博客主亲自录制视频教程) https://study.163.com/course/introduction.htm?courseId=1005214003&am ...
- [源码分析]StringBuilder
[源码分析]StringBuilder StringBuilder是继承自AbstractStringBuilder的. 这里附上另外两篇文章的连接: AbstractStringBuilder : ...
- Java虚拟机—Java8内存模型(整理版)
1.概述 对于Java程序员来说,在虚拟机自动内存管理机制的帮助下,不再需要手动释放内存,不容易出现内存泄露和内存溢出问题.一旦出现内存泄露和溢出方面的问题,如果不了解虚拟机是怎样使用内存的,排查错误 ...
- gantt project 使用
市场上有不少项目计划类系统, 很多都是收费的, 还有很多都是web版, 这些都自然被排除了. 免费好用的还真不多, 今天简单介绍一下 gantt project 这个软件, 开源并且免费, 基于 ja ...
- 20155324《网络对抗》Exp1 PC平台逆向破解(5)M
20155324<网络对抗>Exp1 PC平台逆向破解(5)M 实验目标 本次实践的对象是一个名为~pwn1~的~linux~可执行文件. 该程序正常执行流程是:~main~调用~foo~ ...
- window.location的方法属性详解
示例URL:http://b.a.com:88/index.php?name=kang&when=2011#first 属性 含义 值 protocol: 协议 "http:&quo ...
- java项目部署常用linux命令
1.显示当前所有java进程pid的命令:jps2.查找文件或文件夹目录查找目录:find /(查找范围) -name '查找关键字' -type d查找文件:find /(查找范围) -name 查 ...
- android 应用程序记录AAR
@note:接着读赵波的<android NFC开发实例详解>,单独列出这篇文章一是因为上一篇笔记太长了,网页编辑器不太方便编写,二是这部分的知识是android开发中的知识,以后也许会深 ...
- Java编程思想(后)
Java编程思想(后) 持有对象 如果一个程序只包含固定数量的且其生命期都是已知的对象,那么这是一个非常简单的程序. Java中的库基本类型: List, Set, Queue和Map --- 称为集 ...
- MVC或WebAPI发布后报错404问题的总结
在MVC项目或者webAPI项目发布之后有时会发生404错误.针对这种错误的解决办法: 解决办法1(不推荐):在webconfig中 <system.webServer> 节点下 添加 & ...