2018 Multi-University Training Contest 9----HDU - 6424 Rikka with Time Complexity

Bryce1010模板

https://vjudge.net/problem/HDU-6424

题意:
给出
f(a1)f(a2)f(a3) f ( a 1 ) f ( a 2 ) f ( a 3 ) f(b1)f(b2)f(b3) f ( b 1 ) f ( b 2 ) f ( b 3 ) 比较两者的大小。
fa(n) f a ( n ) 表示有n个log…log(n)

The first line contains a single number t(1≤t≤105), the number of testcases.

For each testcase, the first line contains two integers a,b(1≤a,b≤3), the length of A and B.

The second line contains a integers Ai and the third line contains b integers Bi(1≤Ai,Bi≤109), which describe A and B.

题解:
https://www.bilibili.com/video/av29887345(jls讲解视频)
由于数据范围a,b都是1-3
所以可以对两个公式取两个对数,得到结果为:
f(a1+2)+f(a2+1)f(a3) f ( a 1 + 2 ) + f ( a 2 + 1 ) ∗ f ( a 3 )
fa(n) f a ( n ) 表示有n个log…log(n)
假设f(a1+2)为f(a1+2)*f(inf)
因为inf个log值为1.
所以化简为 f(a)f(b) f ( a ) ∗ f ( b ) f(c)f(d) f ( c ) ∗ f ( d ) 比较的形式。
k1=f(a1+2)f(inf) k 1 = f ( a 1 + 2 ) ∗ f ( i n f )
k2=f(a2+1)f(a3) k 2 = f ( a 2 + 1 ) ∗ f ( a 3 )
k3=f(b1+2)f(inf) k 3 = f ( b 1 + 2 ) ∗ f ( i n f )
k4=f(b2+1)f(b3) k 4 = f ( b 2 + 1 ) ∗ f ( b 3 )
比较的时候,比较min(k1,k2)和min(k3,k4)先比较,然后再比较max(k1,k2)和max(k3,k4)。

#include
using namespace std;
#define ll long long
const int inf=2e9;
int n,m,mod;
ll A[10],B[10];

struct Node
{
    int x,y;
    Node(){}
    Node(int _x,int _y)
    {
       x=_x;y=_y;
       x=min(x,inf);y=min(y,inf);
       if(x>y)swap(x,y);
    }
}node[10];

int cmp(Node a,Node b)
{
    if(a.xreturn 1;if(a.x>b.x)return -1;
    if(a.yreturn 1;if(a.y>b.y)return -1;
    return 0;
}


int main()
{
    int t;
    scanf("%d",&t);
    while(t--)
    {
        scanf("%d%d",&n,&m);
        for(int i=1;i<=3;i++)
            A[i]=inf,B[i]=inf;
        for(int i=1;i<=n;i++)
        {
            scanf("%lld",&A[i]);
        }
        for(int i=1;i<=m;i++)
            scanf("%lld",&B[i]);
        A[1]=A[1]+2,B[1]=B[1]+2;
        A[2]=A[2]+1,B[2]=B[2]+1;
        Node k1=Node{A[1],inf};
        Node k2=Node{A[2],A[3]};
        Node k3=Node{B[1],inf};
        Node k4=Node{B[2],B[3]};
        if(cmp(k1,k2)==-1)swap(k1,k2);
        if(cmp(k3,k4)==-1)swap(k3,k4);
        int w=cmp(k1,k3);
        if(w)
        {
            cout<continue;
        }
        else cout<return 0;
}

你可能感兴趣的:(2018 Multi-University Training Contest 9----HDU - 6424 Rikka with Time Complexity)