Codeforces Round #333 (Div. 2) A. Two Bases

题意:比较两个进制数大小
#include<stdio.h>
#include<string.h>
#include<algorithm>
using namespace std;
#define LL unsigned long long
const LL maxm=200;
LL a[maxm];
LL b[maxm];
LL pow(LL n,LL k)//n的K次方
{
    LL sum=1;
    for(LL i=1;i<=k;i++)
    {
        sum*=n;
    }
    return sum;
}
int main()
{
    LL n1,k1,n2,k2;
    while(scanf("%lld%lld",&n1,&k1)!=EOF)
    {
        LL X=0,Y=0;
        for(LL i=1;i<=n1;i++)
        {
            scanf("%lld",&a[i]);
        }
        scanf("%lld%lld",&n2,&k2);
        for(LL i=1;i<=n2;i++)
        {
            scanf("%lld",&b[i]);
        }
        for(LL i=n1;i>=1;i--)
        {
            X+=(pow(k1,n1-i)*a[i]);
        }
        for(LL i=n2;i>=1;i--)
        {
            Y+=(pow(k2,n2-i)*b[i]);
        }
        if(X<Y)
        {
            printf("<\n");
        }
        else if(X==Y)
        {
            printf("=\n");
        }
        else
        {
            printf(">\n");
        }
    }
    return 0;
}

你可能感兴趣的:(Codeforces Round #333 (Div. 2) A. Two Bases)