题目链接:

hdu:http://acm.hdu.edu.cn/showproblem.php?pid=5170

bc(中文):http://bestcoder.hdu.edu.cn/contests/contest_chineseproblem.php?cid=567&pid=1001

题解:

先用java大数幂写的,t了

 import java.util.*;
import java.math.*;
public class Main {
public static void main(String args[]){
Scanner cin = new Scanner(System.in);
BigInteger a,c;
int b,d; while(cin.hasNext()){
a=cin.nextBigInteger();
b=cin.nextInt();
c=cin.nextBigInteger();
d=cin.nextInt(); a=a.pow(b);
c=c.pow(d);
//四则运算 if(a.compareTo(c)>0) System.out.println(">");
else if(a.compareTo(c)<0) System.out.println("<");
else System.out.println("=");
}
}
}

然后用java写了一个大数的快速幂,同t

 import java.util.*;
import java.math.*;
public class Main {
public static BigInteger solve(BigInteger a,int n){
BigInteger ret=BigInteger.ONE;
// System.out.println("a:"+a.toString());
while(n>0){
if((n&1)>0){
// System.out.println("fuck!");
ret=ret.multiply(a);
}
a=a.multiply(a);
n/=2;
}
// System.out.println("ret!"+ret.toString());
return ret;
}
public static void main(String args[]){
Scanner cin = new Scanner(System.in);
BigInteger a,c;
int b,d; while(cin.hasNext()){
a=cin.nextBigInteger();
b=cin.nextInt();
c=cin.nextBigInteger();
d=cin.nextInt(); a=solve(a,b);
c=solve(c,d); // System.out.println(a.toString());
// System.out.println(c.toString());
//四则运算 if(a.compareTo(c)>0) System.out.println(">");
else if(a.compareTo(c)<0) System.out.println("<");
else System.out.println("=");
}
}
}

终于意识到,只要转化为等幂,比较底数大小就可以了。。

a^b,(c^(d/b))d,只要比较a和c^(d/b)的大小。

第一发,没考虑进度,wa了

 #include<iostream>
#include<cstring>
#include<cmath>
using namespace std; int main() {
int a, b, c, d;
while (scanf("%d%d%d%d", &a, &b, &c, &d) == ) {
double tmp = d*1.0 / b;
tmp = pow(c*1.0, tmp);
if (a*1.0 > tmp) puts(">");
else if (a*1.0 < tmp) puts("<");
else puts("=");
}
return ;
}

贴正解:。。

 #include<iostream>
#include<cstring>
#include<cmath>
using namespace std; const double eps = 1e-; int main() {
int a, b, c, d;
while (scanf("%d%d%d%d", &a, &b, &c, &d) == ) {
double tmp = d*1.0 / b;
tmp = pow(c*1.0, tmp);
if (a*1.0-tmp>eps) puts(">");
else if (a*1.0 - tmp<-eps) puts("<");
else puts("=");
}
return ;
}

总结:

1、不要太冲动,一有想法就上键盘,多考虑下是否有更简单的解决方案。

2、写浮点数,一定要考虑精度!!!!,罚时伤不起。。

HDU 5170 GTY's math problem 水题的更多相关文章

  1. hdu 5170 GTY's math problem(水,,数学,,)

    题意: 给a,b,c,d. 比较a^b和c^d的大小 思路: 比较log(a^b)和log(c^d)的大小 代码: int a,b,c,d; int main(){ while(scanf(" ...

  2. HDU 5170 GTY's math problem

    数学题,a的b次方和c的d次方都很大,直接判断是做不出来的. 如果我们能找到一个函数F(x)是单调的,而F(X)的值又比较好算,那么可以通过比较F(X)的大小来判断自变量的大小. 令F(X)=log( ...

  3. Codeforces Round #602 (Div. 2, based on Technocup 2020 Elimination Round 3) A. Math Problem 水题

    A. Math Problem Your math teacher gave you the following problem: There are n segments on the x-axis ...

  4. HDU 2096 小明A+B --- 水题

    HDU 2096 /* HDU 2096 小明A+B --- 水题 */ #include <cstdio> int main() { #ifdef _LOCAL freopen(&quo ...

  5. HDU 4706 Children's Day (水题)

    Children's Day Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)To ...

  6. hdu 2117:Just a Numble(水题,模拟除法运算)

    Just a Numble Time Limit: 3000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Tot ...

  7. hdu 2050:折线分割平面(水题,递归)

    折线分割平面 Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total Subm ...

  8. hdu 2044:一只小蜜蜂...(水题,斐波那契数列)

    一只小蜜蜂... Time Limit: / MS (Java/Others) Memory Limit: / K (Java/Others) Total Submission(s): Accepte ...

  9. [HDU 2602]Bone Collector ( 0-1背包水题 )

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=2602 水题啊水题 还给我WA了好多次 因为我在j<w[i]的时候状态没有下传.. #includ ...

随机推荐

  1. Java使用JodaTime处理时间

    简介 在Java中处理日期和时间是很常见的需求,基础的工具类就是我们熟悉的Date和Calendar,然而这些工具类的api使用并不是很方便和强大,于是就诞生了Joda-Time这个专门处理日期时间的 ...

  2. 关于if与switch的使用与区别

    这是if语句: if (条件表达式1){ //条件判断 //n多语句1 }else if(条件表达式2){ //n多语句2 }else if(条件表达式3){ //n多语句3 } ... ... el ...

  3. ElasticSearch 安装root用户启动失败问题解决

    1. 下载ElasticSearch 2.3.3 2.  安装JDK 1.8.0以上版本 3.  ElasticSearch 安装时会出现 Exception in thread "main ...

  4. s3c6410 RomCode文档读后总结

    最近无意中看到一篇关于s3c6410 RomCode的介绍,结合自己的经验,做个总结. 首先贴张图,具体描述下该芯片的启动方式及具体流程. 因为s3c6410的板子多数是从SD或者Nand方式启动,重 ...

  5. 海思平台交叉编译curl支持SSL功能

    1.准备工具 1).交叉编译工具 2).下载libcurl和openssl源代码,我使用的是(openssl-1.0.2o.tar,curl-7.59.0.tar) 3).查看cpu详细 ~ # ca ...

  6. SSM 框架基于ORACLE集成TKMYBATIS 和GENERATOR自动生成代码(Github源码)

    基于前一个博客搭建的SSM框架 https://www.cnblogs.com/jiangyuqin/p/9870641.html 源码:https://github.com/JHeaven/ssm- ...

  7. python2.7入门---GUI编程(Tkinter)

        Python 提供了多个图形开发界面的库,几个常用 Python GUI 库如下: Tkinter: Tkinter 模块(Tk 接口)是 Python 的标准 Tk GUI 工具包的接口 . ...

  8. 2016-2017-20155329 《Java程序设计》第十周学习总结

    学号 2016-2017-20155329 <Java程序设计>第十周学习总结 教材学习内容总结 学习目标 了解计算机网络基础 OSI分层(7层):物理层.数据链路层.网络层.传输层.会话 ...

  9. 可能是全网首个支持阿里云Elasticsearch Xapck鉴权的Skywalking

    可能是全网首个支持阿里云Elasticsearch Xapck鉴权的Skywalking 对Skywalking有兴趣的同学参见:年轻人的第一个APM-Skywalking 之前在搭建Skywalki ...

  10. 17、JAVA多线程和并发基础面试问答

    JAVA多线程和并发基础面试问答 原文链接:http://ifeve.com/java-multi-threading-concurrency-interview-questions-with-ans ...