zoukankan      html  css  js  c++  java
  • 【第13届景驰-埃森哲杯广东工业大学ACM程序设计大赛-L】用来作弊的药水

    链接:https://www.nowcoder.com/acm/contest/90/L
    来源:牛客网

    输入x,a,y,b,(1<=x,a,y,b<=10^9)判断x^a是否等于y^b

    前面同时加log,即判断alogx==blogy

     1 #include <bits/stdc++.h>
     2 using namespace std;
     3 int main()
     4 {
     5     int n;
     6     int x,a,y,b;
     7     scanf("%d",&n);
     8     while(n--)
     9     {
    10         scanf("%d%d%d%d",&x,&a,&y,&b);
    11         if(fabs(a*log(x)-b*log(y))<0.1)
    12             printf("Yes
    ");
    13         else
    14             printf("No
    ");
    15     }
    16     return 0;
    17 }

    也可以余上很大的素数

     1 #include <bits/stdc++.h>
     2 using namespace std;
     3 const int mod = 1e9+7;
     4 typedef long long LL;
     5 LL pow(LL a, LL b)
     6 {
     7     LL res = 1;
     8     while(b)
     9     {
    10         if(b&1) res=(res*a)%mod;
    11         a=(a*a)%mod;
    12         b>>=1;
    13     }
    14     return res;
    15 }
    16 int main()
    17 {
    18     LL t, a, b, x, y;
    19     cin>>t;
    20     while(t--)
    21     {
    22         scanf("%lld%lld%lld%lld", &x, &a, &y, &b);
    23         if(pow(x, a) == pow(y, b))
    24             puts("Yes");
    25         else
    26             puts("No");
    27     }
    28     return 0;
    29 }
  • 相关阅读:
    gdb --configuration
    firecracker 编译
    gvisor 编译
    gvisor
    rust Deref
    rust explicit
    rust move
    rust drop
    出租人对经营租赁的会计处理
    关于以公允价值计量的投资性房地产的处置
  • 原文地址:https://www.cnblogs.com/lesroad/p/8641314.html
Copyright © 2011-2022 走看看