题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=6424
题意:看题面吧,贼容易看懂。
题解:因为有最多两层指数,高数上的常规方法是将其取对数使得变成两个数相乘,这样比大小就简单了,见图:
然后就是两项比大小了,肯定是先比大的然后比相对较小的了。。。。
#include<math.h>
#include<stdio.h>
#include<iostream>
#include<string.h>
#include<algorithm>
using namespace std;
const int inf=2e9;
struct node
{
int x,y;
node(int xx,int yy)
{
x=xx;y=yy;
x=min(xx,inf);
y=min(yy,inf);
if(x>y) swap(x,y);
}
};
int comp(node k1,node k2)
{
if (k1.x<k2.x) return 1; else if (k1.x>k2.x) return -1;
if (k1.y<k2.y) return 1; else if (k1.y>k2.y) return -1;
return 0;
}
int check(node k1,node k2,node k3,node k4)
{
int w=comp(k1,k3);
if (w) return w;
return comp(k2,k4);
}
int a[5],b[5],n,m;
int main(void)
{
int T;
scanf("%d",&T);
while(T--)
{
for(int i=1;i<=3;i++)
a[i]=b[i]=inf;
scanf("%d%d",&n,&m);
for(int i=1;i<=n;i++)
scanf("%d",&a[i]);
for(int i=1;i<=m;i++)
scanf("%d",&b[i]);
node t1=node(a[1]+2,inf),t2=node(a[2]+1,a[3]);
node t3=node(b[1]+2,inf),t4=node(b[2]+1,b[3]);
if(comp(t1,t2)==-1) swap(t1,t2);
if(comp(t3,t4)==-1) swap(t3,t4);
printf("%d\n",check(t1,t2,t3,t4));
}
return 0;
}