题目:https://cn.vjudge.net/contest/250938#problem/H
思路:大意就是比较a^b与c^d的大小,数学问题,转换思想,a^b与c^d比大小,也就相当于log(a^b) 与 log(c^d) 比大小
即b*log(a) 与 d*log(c)比大小
因为log涉及double类型的问题,所以输入可以直接用double类型,附AC代码
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
using namespace std;
int main()
{
int t;
double a, b, c, d;
double x, y;
scanf("%d", &t);
while(t--)
{
scanf("%lf%lf%lf%lf", &a, &b, &c, &d);
x = b * log(a);
y = d * log(c);
if(x>=y)printf(">\n");
else printf("<\n");
}
return 0;
}
也可以用int类型,在log处×1.0就OK了,附AC代码
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
using namespace std;
int main()
{
int t;
int a, b, c, d;
double x, y;
scanf("%d", &t);
while(t--)
{
scanf("%d%d%d%d", &a, &b, &c, &d);
x = b * log(a* 1.0);
y = d * log(c* 1.0);
if(x>=y)printf(">\n");
else printf("<\n");
}
return 0;
}