题目链接:传送门
题意就不说了,直接说怎么推的
直接在 求的结果前面+2个log 取对数
loglog(f(a)^f(b)^f(c)) = (log(f(b)^f(c))*log(f(a)) = log(f(b)^f(c)) + loglog(f(a)) = f(c)log(f(b)) + loglog(f(a)) = f(c)f(b+1) + f(a+2)
f(+无穷大) 趋近于1
f(n) n越大 f(n)越小
f(a) 与 f(b)f(c)比较 可化为 f(a)f(+无穷大) 与 f(b)f(c)比较
a+b 与 c+d进行比较 比较max(a,b) 与 max(c,d),相同则比较min(a,b) 与 min(c,d)
AC代码:
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#define inf 0x3f3f3f3f
using namespace std;
struct node {
int x, y;
node(int _x, int _y){//x 为小值 y 为大值
x = _x;
y = _y;
x = min(x, inf);
y = min(y, inf);
if(x > y){
swap(x, y);
}
}
};
int a[3];
int b[3];
int compare(node aa, node bb){
if(aa.x < bb.x){
return 1;
}else if(aa.x > bb.x){
return -1;
}
if(aa.y < bb.y){
return 1;
}else if(aa.y > bb.y){
return -1;
}
return 0;
}
int check(node aa, node bb, node cc, node dd) {
if(compare(aa, cc)){
return compare(aa, cc);
}else {
return compare(bb, dd);
}
}
int main() {
int t;
scanf("%d", &t);
while(t--){
memset(a, inf , sizeof(a));
memset(b, inf , sizeof(b));
int n, m;
scanf("%d%d", &n, &m);
for(int i = 0; i < n; i++){
scanf("%d", &a[i]);
}
for(int i = 0; i < m; i++){
scanf("%d", &b[i]);
}
node k1 = node(a[0]+2, inf), k2 = node(a[1]+1, a[2]);
node k3 = node(b[0]+2, inf), k4 = node(b[1]+1, b[2]);
if(compare(k1, k2) == -1){
swap(k1, k2);// k1 > k2
}
if(compare(k3, k4) == -1){
swap(k3, k4);// k3 > k4
}
printf("%d\n",check(k1,k2,k3,k4));
}
return 0;
}