题目链接:

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. pycharm使用杂记

    R语言解释器在/opt/local/Library/Frameworks/R.framework/Versions/3.5/Resources/bin/R

  2. 记一次MacBook Pro无法连接wifi网络修复

    解决方案: https://blog.csdn.net/kimbing/article/details/79321001 真的哭了 原因是插入了我的USB3.0拓展坞影响了wifi信号 不知道原理是啥 ...

  3. 飞控入门之C语言结构体、枚举

    结构体 先来说明一下,结构体存在的意义.比如说有一只猫,要在C语言程序中综合描述它,那么可以这样说,它的体重是float类型的,颜色是char类型的,它的一些食物名字是一个数组,那么如果分开定义这些变 ...

  4. Vue2.5入门-2

    todolist功能开发 代码 <!DOCTYPE html> <html> <head> <title>vue 入门</title> &l ...

  5. leetcode记录-字符串转整数

    实现 atoi,将字符串转为整数. 该函数首先根据需要丢弃任意多的空格字符,直到找到第一个非空格字符为止.如果第一个非空字符是正号或负号,选取该符号,并将其与后面尽可能多的连续的数字组合起来,这部分字 ...

  6. 20155317 2016-2017-2《Java程序设计》课程总结

    20155317 2016-2017-2<Java程序设计>课程总结 每周作业链接汇总 新玮的首发博客:对师生关系的期望. C语言与java 20155317 王新玮第二次:语言掌握调查 ...

  7. hasOwnProperty()函数

    hasOwnProperty()函数的返回值为Boolean类型.如果对象object具有名称为propertyName的属性,则返回true,否则返回false 例子: function Site( ...

  8. 【CF908G】New Year and Original Order

    [CF908G]New Year and Original Order 题面 洛谷 题解 设\(f[i][j][k][l]\)表示当前在第\(i\)位有\(j\)位大于等于\(k\),当前有没有卡上界 ...

  9. 【转】 线段树完全版 ~by NotOnlySuccess

    载自:NotOnlySuccess的博客 [完全版]线段树 很早前写的那篇线段树专辑至今一直是本博客阅读点击量最大的一片文章,当时觉得挺自豪的,还去pku打广告,但是现在我自己都不太好意思去看那篇文章 ...

  10. toString()方法简单分析

    问题描述 今天在使用spotbugs代码走查时发现这样一个问题,如下, String[] myArray=new String[] {"1","2"," ...