• 题意 :给你两个指数类型的数\(A^m\)和\(B^n\),比较他们的大小.保证底数和指数中最多只有一个为0.

  • 题解 :题目数据非常大,肯定不能直接比较.由换底公式和\(Log\)函数的性质我们知道:\(LogA^m=mLogA\),又因为\(Log\)函数是单增的,我们便可以用它来进行大小的比较.这里要注意当底数为0的时候,指数为0可以不用管.还有要记住!!! double类型比较大小会出现精度的问题,不能直接比,要用一个eps!!!

  • 代码:

    #include <iostream>
    #include <cstdio>
    #include <cstring>
    #include <cmath>
    #include <algorithm>
    #include <stack>
    #include <queue>
    #include <vector>
    #include <map>
    #include <set>
    #include <unordered_set>
    #include <unordered_map>
    #define ll long long
    #define fi first
    #define se second
    #define pb push_back
    #define me memset
    const int N = 1e6 + 10;
    const int mod = 1e9 + 7;
    using namespace std;
    typedef pair<int,int> PII;
    typedef pair<long,long> PLL; const double eps=1e-8;
    int t;
    double res1,res2;
    int b1,p1,b2,p2; int main() {
    ios::sync_with_stdio(false);
    cin>>t;
    while(t--){
    cin>>b1>>p1>>b2>>p2;
    if(b1==0 || b2==0){
    if(b1>b2) puts("HaHa");
    else if(b1<b2) puts("Congrats");
    else puts("Lazy");
    continue;
    }
    res1=log(1.0*b1)*p1*1.0;
    res2=log(1.0*b2)*p2*1.0;
    if(fabs(res1-res2)<eps) puts("Lazy");
    else if(res1<res2) puts("Congrats");
    else puts("HaHa");
    }
    return 0;
    }

最新文章

  1. 无法解决“Microsoft.SharePoint.Security, Version=15.0.0.0,”与“Microsoft.SharePoint.Security, Version=14.0.0.0”之间的冲突
  2. 结构体内嵌函数指针实现C语言面向对象
  3. JS详细入门教程(上)
  4. JDBC + MySQL 示例
  5. Cdnbes负载均衡的权重用法解释
  6. RequireJS 循环依赖报 模块undefined 处理方案
  7. SQL基础巩固1
  8. VBS定时关闭的弹窗
  9. JAVA_BaseDAO数据处理类
  10. TVideoGrabber的使用(一)捕捉摄像头
  11. centos6.5 64bit 实现root开机自动登录X桌面
  12. 关于TCP协议握手的那些事儿
  13. 我的日常工具——gdb篇
  14. 【转】selenium及webdriver的原理
  15. 黑马程序员 c#单态的设计模式 (专题二)
  16. ImageView的子类无法加载图片
  17. Neutron网络-OPENSTACK讲得比较透和方便
  18. MongoDB Sharding
  19. LeetCode &amp; Q14-Longest Common Prefix-Easy
  20. Python内置函数(40)——map

热门文章

  1. 跟我一起学Redis之加个哨兵让主从复制更加高可用
  2. 2021年正确的Android逆向开发学习之路
  3. python—base64
  4. win10打开IIS服务并发布网站
  5. Chrome Performance性能分析面板使用
  6. bean与map之间的转化
  7. ReactRouter的实现
  8. ASP Net Core &ndash; CORS 预检请求
  9. Linux防火墙和iptables
  10. 解决 browser-sync start --server --files 文件不能同步的问题!