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

题意:
给一个n和b,还有n个数,代表数A由这n个数的b进制组成
比如
3 2
1 0 1就是5
然后再给一个n,b和n个数得出数B,问A?B,?是>,<或=
思路:
模拟,记得long long 就行了

#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
using namespace std;
#define lowbit(x) (x&(-x))
typedef long long LL;
const int maxn = 10005;
const int inf=(1<<28)-1;
int A[maxn];
int main()
{
    int n,a;
    scanf("%d%d",&n,&a);
    for(int i=1;i<=n;++i)
    scanf("%d",&A[i]);
    LL tmp=A[1];
    for(int i=2;i<=n;++i)
    {
        tmp*=a;
        tmp+=A[i];
    }
    scanf("%d%d",&n,&a);
    for(int i=1;i<=n;++i)
    scanf("%d",&A[i]);
    LL res=A[1];
    for(int i=2;i<=n;++i)
    {
        res*=a;
        res+=A[i];
    }
    //printf("%lld %lld\n",tmp,res);
    if(tmp==res) printf("=\n");
    else if(tmp>res) printf(">\n");
    else printf("<\n");
    return 0;
}

你可能感兴趣的:(codeforces,其他)