题目链接:

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. vue中渲染页面,动态设置颜色

    for循环中动态设置页面的图标或者字体颜色与循环中且套循环 :style="{'color':items.color}" 案例代码: html中 <div class=&qu ...

  2. 针对shiro框架authc拦截器认证成功后跳转到根目录,而非指定路径问题

    一.针对shiro框架authc拦截器认证成功后跳转到根目录,而非指定路径问题 首先,我们先来了解一下authc登录拦截器工作原理 authc拦截器有2个作用: 1>登录认证     请求进来时 ...

  3. 搭建php服务器网站

    一.Apache安装 yum install httpd启动systemctl start httpd.service #启动systemctl stop httpd.service #停止syste ...

  4. CDH部署(以5.7.5为例)

    博客园首发,转载请注明出处https://www.cnblogs.com/tzxxh/p/9120020.html 一.准备工作(下面的内容括号内写master的表示仅在master节点执行,all代 ...

  5. Windows系统Python 虚拟环境virtualenv安装

    1.我们用pip安装virtualenv >pip3 install virtualenv 2.创建工程目录 >mkdir myproject 3.进入工程目录 >cd myproj ...

  6. sklearn的train_test_split,果然很好用啊!

    sklearn的train_test_split   train_test_split函数用于将矩阵随机划分为训练子集和测试子集,并返回划分好的训练集测试集样本和训练集测试集标签. 格式: X_tra ...

  7. fgets()

    fgets()函数简介 读字符串函数fgets()的功能是从指定的文件中读一个字符串到字符数组中,函数调用的形式为: fgets(字符数组名,n,文件指针),要从键盘输入时文件指针的参数为:stdin ...

  8. Git 命令及使用经验

    手册中的基本命令: CONFIGURE TOOLING Configure user information for all local repositories $ git config --glo ...

  9. 20155213 实验四 Android程序设计

    20155213 实验四 Android程序设计 实验内容 基于Android Studio开发简单的Android应用并部署测试; 了解Android组件.布局管理器的使用: 掌握Android中事 ...

  10. 20155301 2016-2017-2 《Java程序设计》第4周学习总结

    20155301 2016-2017-2 <Java程序设计>第4周学习总结 教材学习内容总结 1.关键词extends,表示SwordsMan会扩充Role的行为,然后再扩充Role原本 ...