Description
给出一个bx进制的n位数和一个by进制的m位数,比大小
Input
第一行两整数n和bx表示第一个数的长度和进制,然后n个数表示这个数的每一位,然后两整数m和by表示第二个数的长度和进制,然后m个数表示这个数的每一位(1<=n,m<=10,2<=bx,by<=40)
Output
第一个数大于第二个数则输出>,等于则输出=,小于则输出<
Sample Input
6 2
1 0 1 1 1 1
2 10
4 7
Sample Output
=
Solution
水题,40^10没爆long long,直接求出这两个数比个大小即可
Code
#include<cstdio>
#include<iostream>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<vector>
#include<queue>
#include<map>
#include<set>
#include<ctime>
using namespace std;
typedef long long ll;
#define INF 0x3f3f3f3f
#define maxn 1111
int main()
{
int n,m,x,y;
ll a,b;
while(~scanf("%d%d",&n,&x))
{
a=b=0;
for(int i=1;i<=n;i++)
{
int temp;
scanf("%d",&temp);
a=a*x+temp;
}
scanf("%d%d",&m,&y);
for(int i=1;i<=m;i++)
{
int temp;
scanf("%d",&temp);
b=b*y+temp;
}
if(a<b)printf("<\n");
else if(a==b)printf("=\n");
else printf(">\n");
}
return 0;
}