solution
stringlengths
11
983k
difficulty
int64
0
21
language
stringclasses
2 values
#include <bits/stdc++.h> using namespace std; inline bool EQ(double a, double b) { return fabs(a - b) < 1e-9; } int main() { int a, x, i; int ar[15]; long long int powr = 1; long long int ans1, ans2; ans1 = ans2 = 0; scanf("%d", &a); scanf("%d", &x); for (i = 0; i < a; i++) scanf("%d", &ar[i]); for (i = a - 1; i >= 0; i--) ans1 += powr * ar[i], powr *= x; scanf("%d", &a); scanf("%d", &x); powr = 1; for (i = 0; i < a; i++) scanf("%d", &ar[i]); for (i = a - 1; i >= 0; i--) ans2 += powr * ar[i], powr *= x; if (ans1 == ans2) printf("=\n"); else if (ans1 < ans2) printf("<\n"); if (ans1 > ans2) printf(">\n"); return 0; }
7
CPP
n, bx = [int(var) for var in input().split()] x = [int(var) for var in input().split()] m, by = [int(var) for var in input().split()] y = [int(var) for var in input().split()] def findnum(b, db): num = 0 for dig in db: num *= b num += dig return num ax = findnum(bx, x) ay = findnum(by, y) if ax < ay: print('<') elif ax == ay: print('=') else: print('>')
7
PYTHON3
def readnum(): n, b = (int(w) for w in input().split()) x = 0 nums = list(int(w) for w in input().split()) return sum(nums[i] * b**(n-1-i) for i in range(n)) x = readnum() y = readnum() if x==y: print('=') if x<y: print('<') if x>y: print('>')
7
PYTHON3
n, b1 = map(int, input().split()) a = list(map(int, input().split())) m, b2 = map(int, input().split()) b = list(map(int, input().split())) num1 = 0 num2 = 0 for i in range(n): num1 += a[i] * (b1 ** (n - i - 1)) for i in range(m): num2 += b[i] * (b2 ** (m - i - 1)) if (num1 == num2): print('=') elif (num1 > num2): print('>') else: print('<')
7
PYTHON3
n, bx = map(int, input().split()) x = list(map(int, input().split())) m, by = map(int, input().split()) y = list(map(int, input().split())) xx = bx ** (n - 1) yy = by ** (m - 1) ansx = 0 ansy = 0 for i in range(n): ansx += x[i] * xx xx //= bx for i in range(m): ansy += y[i] * yy yy //= by if ansx > ansy: print('>') elif ansx < ansy: print('<') else: print('=')
7
PYTHON3
#include <bits/stdc++.h> using namespace std; unsigned long long a, b; int main() { long long int n, c, k = 1; cin >> n >> c; for (int i = 0; i < n - 1; i++) k *= c; for (int i = 0; i < n; i++) { long long int l; cin >> l; a += l * k; k /= c; } cin >> n >> c; k = 1; for (int i = 0; i < n - 1; i++) k *= c; for (int i = 0; i < n; i++) { int l; cin >> l; b += l * k; k /= c; } if (a > b) cout << ">"; if (a < b) cout << "<"; if (a == b) cout << "="; }
7
CPP
#include <bits/stdc++.h> int main() { int an, a, bm, b, i, j, x; long long resa = 0, resb = 0; scanf("%d %d", &an, &a); j = an; for (i = 0; i < an; ++i) { scanf("%d", &x); resa = resa + x * pow(double(a), double(--j)); } scanf("%d %d", &bm, &b); j = bm; for (i = 0; i < bm; ++i) { scanf("%d", &x); resb = resb + x * pow(double(b), double(--j)); } if (resb == resa) printf("=\n"); else if (resa > resb) printf(">\n"); else printf("<\n"); return 0; }
7
CPP
#include <bits/stdc++.h> using namespace std; int c[1000]; int main() { long long a = 0, b = 0, j = 1; int n, m; scanf("%d%d", &n, &m); for (int i = n; i >= 1; i--) scanf("%d", &c[i]); for (int i = 1; i <= n; i++) { a += c[i] * j; j *= m; } scanf("%d%d", &n, &m); for (int i = n; i >= 1; i--) scanf("%d", &c[i]); j = 1; for (int i = 1; i <= n; i++) { b += j * c[i]; j *= m; } if (a > b) printf(">"); else if (a == b) printf("="); else printf("<"); return 0; }
7
CPP
#include <bits/stdc++.h> using namespace std; int main() { long long n, bx, x = 0, y = 0; cin >> n >> bx; while (n--) { int a; cin >> a; x = x * bx + a; } cin >> n >> bx; while (n--) { int a; cin >> a; y = y * bx + a; } if (x > y) cout << ">\n"; if (x < y) cout << "<\n"; if (x == y) cout << "=\n"; }
7
CPP
n,b=map(int,input().split()) X=0 for x in list(map(int,input().split())): n-=1 X+=x*(b**n) m,a=map(int,input().split()) Y=0 for y in list(map(int,input().split())): m-=1 Y+=y*(a**m) if X<Y: print("<") elif X>Y: print(">") else: print("=")
7
PYTHON3
#include <bits/stdc++.h> using namespace std; template <class T> inline T bigmod(T p, T e, T M) { long long ret = 1; for (; e > 0; e >>= 1) { if (e & 1) ret = (ret * p) % M; p = (p * p) % M; } return (T)ret; } template <class T> inline T gcd(T a, T b) { if (b == 0) return a; return gcd(b, a % b); } template <class T> inline T modinverse(T a, T M) { return bigmod(a, M - 2, M); } int Set(int N, int pos) { return N = N | (1 << pos); } int Reset(int N, int pos) { return N = N & ~(1 << pos); } bool Chkbit(int N, int pos) { return (bool)(N & (1 << pos)); } int month[] = {-1, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}; int dx[] = {1, 0, -1, 0}; int dy[] = {0, 1, 0, -1}; const double eps = 1e-6; long long a[15], b[15]; int n, m, bx, by; long long pw(int aa, int bb) { long long sum = 1; for (int i = 0; i < bb; i++) sum *= (long long)aa; return sum; } long long conv(int f, int base) { long long sum = 0; if (f == 1) { for (int i = n - 1, j = 0; i >= 0; i--, j++) sum += a[i] * pw(base, j); } else { for (int i = m - 1, j = 0; i >= 0; i--, j++) sum += b[i] * pw(base, j); } return sum; } int main() { ios_base::sync_with_stdio(0); cin.tie(0); cin >> n >> bx; for (int i = 0; i < n; i++) cin >> a[i]; cin >> m >> by; for (int i = 0; i < m; i++) cin >> b[i]; long long res = conv(1, bx); long long res2 = conv(0, by); if (res > res2) cout << ">" << endl; else if (res < res2) cout << "<" << endl; else cout << "=" << endl; return 0; }
7
CPP
#include <bits/stdc++.h> using namespace std; long long x, y; int main() { int n, b, m; cin >> n >> b; for (int i = 0; i < n; i++) { cin >> m; x = x * b + m; } cin >> n >> b; for (int i = 0; i < n; i++) { cin >> m; y = y * b + m; } if (x < y) cout << '<'; else { if (x > y) cout << '>'; else cout << '='; } return 0; }
7
CPP
x=0 y=0 n=0 a,b = map(int,input().split()) nums1 = [int(n) for n in input().split()] c,d = map(int,input().split()) nums2 = [int(n) for n in input().split()] for i in range(a-1,-1,-1): coeff=nums1[i] x=x+coeff*(b**(a-i-1)) for i in range(c-1,-1,-1): coeff=nums2[i] y=y+coeff*(d**(c-i-1)) if x<y: print('<') elif x>y: print('>') elif x==y: print('=') else: print('error')
7
PYTHON3
_,b = map(int,input().split()) one = 0 for i in [int(x) for x in input().split()]: one = one*b+i _,b = map(int,input().split()) two = 0 for i in [int(x) for x in input().split()]: two = two*b+i if one<two: print('<') if one>two: print('>') if one==two: print('=')
7
PYTHON3
#include <bits/stdc++.h> using namespace std; long long int power(long long int a, long long int b) { long long int ans = 1; while (b) { if (b % 2 == 1) ans = ans * a; b = b / 2; a = a * a; } return ans; } int main() { long long int first = 0, second = 0; long long int n, b; scanf("%lld %lld", &n, &b); long long int A[100]; for (int i = 0; i < n; i++) { scanf("%lld", &A[i]); } long long int j = 0; for (int i = n - 1; i >= 0; i--) { first = first + power(b, j++) * A[i]; } scanf("%lld %lld", &n, &b); for (int i = 0; i < n; i++) { scanf("%lld", &A[i]); } j = 0; for (int i = n - 1; i >= 0; i--) { second = second + power(b, j++) * A[i]; } if (first == second) printf("=\n"); else if (first > second) printf(">\n"); else printf("<\n"); }
7
CPP
'''input 3 3 1 0 2 2 5 2 4 ''' n, b1 = map(int, input().split()) x = list(map(int, input().split()))[::-1] m, b2 = map(int, input().split()) y = list(map(int, input().split()))[::-1] sx, sy = 0, 0 for i in range(n): sx += b1**(i) * x[i] for j in range(m): sy += b2**(j) * y[j] if sx == sy: print("=") else: print("<" if sx < sy else ">")
7
PYTHON3
#include <bits/stdc++.h> using namespace std; int main() { long long int i, j, k, l, m, n, x, y, bx, by, l1, l2, s1[15], s2[15]; scanf("%lld %lld", &l1, &bx); for (i = 0; i < l1; i++) scanf("%lld", &s1[i]); scanf("%lld %lld", &l2, &by); for (i = 0; i < l2; i++) scanf("%lld", &s2[i]); for (i = 0, x = 0; i < l1; i++) { x = x * bx + s1[i]; } for (i = 0, y = 0; i < l2; i++) { y = y * by + s2[i]; } if (x < y) printf("<\n"); else if (x == y) printf("=\n"); else printf(">\n"); return 0; }
7
CPP
#include <bits/stdc++.h> using namespace std; int main() { long long n, b, m, x = 0, y = 0; string s1, s2; cin >> n >> b; while (n--) { int a; cin >> a; x *= b; x += a; } cin >> n >> b; while (n--) { int a; cin >> a; y *= b; y += a; } if (x > y) { cout << ">" << endl; return 0; } if (x < y) { cout << "<" << endl; return 0; } if (x == y) { cout << "=" << endl; return 0; } return 0; }
7
CPP
#include <bits/stdc++.h> using namespace std; long long cal(int x, int y) { long long ans = 1; for (int i = 1; i <= y; i++) { ans *= x; } return ans; } int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); long long n, x; long long m, y; long long a, b; long long sum1 = 0, sum2 = 0; cin >> n >> x; for (int i = n - 1; i >= 0; --i) { cin >> a; sum1 += (a * cal(x, i)); } cin >> m >> y; for (int i = m - 1; i >= 0; --i) { cin >> b; sum2 += b * cal(y, i); } if (sum1 == sum2) puts("="); else if (sum1 > sum2) puts(">"); else puts("<"); return 0; }
7
CPP
#include <bits/stdc++.h> using namespace std; int main() { long long int n, base, number1 = 0, number2 = 0; int temp; vector<int> numbers; cin >> n >> base; while (n--) cin >> temp, numbers.insert(numbers.begin(), temp); for (long long int i = 0, j = 1; i < numbers.size(); i++, j *= base) number1 += j * numbers[i]; numbers.clear(); cin >> n >> base; while (n--) cin >> temp, numbers.insert(numbers.begin(), temp); for (long long int i = 0, j = 1; i < numbers.size(); i++, j *= base) number2 += j * numbers[i]; if (number1 == number2) cout << "=" << endl; else if (number1 < number2) cout << "<" << endl; else cout << ">" << endl; return 0; }
7
CPP
import sys n,bx = map(int,input().split()) a = list(map(int,input().split())) m,by = map(int,input().split()) b = list(map(int,input().split())) x = p = 0 for i in range(n-1,-1,-1): x += a[i]*(bx**p) p += 1 y = p = 0 for i in range(m-1,-1,-1): y += b[i]*(by**p) p += 1 if x < y: print('<') elif x > y: print('>') else: print('=')
7
PYTHON3
#include <bits/stdc++.h> using namespace std; int main() { int n = 0; int bx = 0; vector<int> X; int m = 0; int by = 0; vector<int> Y; scanf("%d", &n); scanf("%d", &bx); for (int i = 0; i < n; ++i) { int var; scanf("%d", &var); X.push_back(var); } scanf("%d", &m); scanf("%d", &by); for (int i = 0; i < m; ++i) { int var; scanf("%d", &var); Y.push_back(var); } double x_dec = 0; double y_dec = 0; double p_x = 0; for (int i = X.size() - 1; i >= 0; --i) { x_dec += X.at(i) * (pow(bx, p_x)); p_x = p_x + 1; } double p_y = 0; for (int i = Y.size() - 1; i >= 0; --i) { y_dec += Y.at(i) * (pow(by, p_y)); p_y++; } if (x_dec == y_dec) { cout << "=" << endl; } else if (x_dec > y_dec) { cout << ">" << endl; } else { cout << "<" << endl; } return 0; }
7
CPP
ar = [0, 0] for i in range(0, 2): [n, b] = [int(x) for x in input().split()] for x in [int(x) for x in input().split()]: ar[i] *= b ar[i] += x if ar[0] == ar[1]: print('=') elif ar[0] > ar[1]: print('>') else: print('<')
7
PYTHON3
x=0 y=0 n,m= input().split() n=int(n) m=int(m) for z in input().split(): x=x*m+int(z) n,m= input().split() n=int(n) m=int(m) for z in input().split(): y=y*m+int(z) if x==y: print('=') elif x>y: print('>') else: print('<')
7
PYTHON3
n1 = 0 n, b = map(int, input().split()) a = list(map(int, input().split())) a.reverse() for i in range(n): n1 += a[i] * (b ** i) n2 = 0 n, b = map(int, input().split()) a = list(map(int, input().split())) a.reverse() for i in range(n): n2 += a[i] * (b ** i) if n1 < n2: print("<") if n1 == n2: print("=") if n1 > n2: print(">")
7
PYTHON3
n,bx=input().split() bx=int(bx) x=input() a=[int(i) for i in x.split()] m,by=input().split() by=int(by) y=input() b=[int(i) for i in y.split()] vbx=0 for i in range(len(a)): vbx=vbx+(bx**(len(a)-i-1))*a[i] vby=0 for i in range(len(b)): vby=vby+(by**(len(b)-i-1))*b[i] if(vbx<vby): print('<') elif(vbx==vby): print('=') else: print('>')
7
PYTHON3
#include <bits/stdc++.h> using namespace std; long long int sum1, sum2; int main() { long long int digit, base, tmp, sum; scanf("%I64d %I64d", &digit, &base); for (int i = 1; i <= digit; i++) { scanf("%I64d", &tmp); sum1 = sum1 * base + tmp; } scanf("%I64d %I64d", &digit, &base); for (int i = 1; i <= digit; i++) { scanf("%I64d", &tmp); sum2 = sum2 * base + tmp; } sum1 == sum2 ? putchar('=') : sum1 > sum2 ? putchar('>') : putchar('<'); return 0; }
7
CPP
I = lambda: map(int, input().split()) n, b = I() X = sum(x*b**(n-i) for i,x in enumerate(I(),1)) n, b = I() Y = sum(y*b**(n-i) for i,y in enumerate(I(),1)) print('<' if X<Y else '>' if X>Y else '=')
7
PYTHON3
nx, bx = map(int, input().split()) x = list(map(int, input().split())) ny, by = map(int, input().split()) y = list(map(int, input().split())) def todec(x , b): res = 0 exp = len(x) -1 for i in x: res += i * b ** exp exp -= 1 return res x = todec(x, bx) y = todec(y, by) if x > y: print(">") elif x < y: print("<") else: print("=")
7
PYTHON3
def get(): N, B = map(int, input().split()) res = 0 for i in input().split(): res = B * res + int(i) return res x = get() y = get() if x < y: print('<') elif x > y: print('>') else: print('=')
7
PYTHON3
def trans( nums , n , b ): res = 0 for i in range( n ): res = res*b+nums[i] #print( i , ":" , res ) return res if __name__ == "__main__": n , bx = [int(x) for x in input().split()] numXArray = [int(x) for x in input().split()] numX = trans( numXArray , n , bx ) #print( numX ) m , by = [int(x) for x in input().split()] numYArray = [int(x) for x in input().split()] numY = trans( numYArray , m , by ) #print( numY ) if numX < numY: print("<") elif numX > numY: print(">") else: print("=")
7
PYTHON3
__author__ = 'MoonBall' import sys # sys.stdin = open('data/A.in', 'r') T = 1 def t(): N, A = map(int, input().split()) a = list(map(int, input().split())) ans = 0 for v in a: ans = ans * A + v return ans def process(): X = t() Y = t() print('=' if X == Y else '<' if X < Y else '>') for _ in range(T): process()
7
PYTHON3
#include <bits/stdc++.h> using namespace std; int main() { int N; cin >> N; long long base; cin >> base; long long a = 0; for (int i = 0; i < N; i++) { long long tmp; cin >> tmp; a = a * base + tmp; } long long b = 0; cin >> N >> base; for (int i = 0; i < N; i++) { long long tmp; cin >> tmp; b = b * base + tmp; } if (b == a) { cout << "=\n"; } else if (b > a) { cout << "<\n"; } else { cout << ">\n"; } return 0; }
7
CPP
I = input n, bx = map(int, I().split()) x = list(map(int, I().split())) m, by = map(int, I().split()) y = list(map(int, I().split())) x10 = sum(x[i]*bx**(n-i-1) for i in range(n)) y10 = sum(y[i]*by**(m-i-1) for i in range(m)) if x10 == y10: print('=') elif x10 < y10: print('<') else: print('>')
7
PYTHON3
#include <bits/stdc++.h> using namespace std; const int inf = 0x3f3f3f3f; const long long INF = 0x3f3f3f3f3f3f3f3f; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); int x, y; while (cin >> x >> y) { long long a1 = 0; long long a2 = 0; for (int i = 1; i <= x; i++) { int t; cin >> t; a1 = a1 * y + t; } int c, d; cin >> c >> d; for (int i = 1; i <= c; i++) { int t; cin >> t; a2 = a2 * d + t; } if (a1 < a2) cout << "<" << endl; else if (a1 == a2) cout << "=" << endl; else cout << ">" << endl; } }
7
CPP
#include <bits/stdc++.h> using namespace std; int main() { long long n, i, j, k, x, m, l, sum1 = 0, sum2 = 0, jha = 1; vector<long long int> v, v1; cin >> n >> k; for (i = 0; i < n; i++) { cin >> x; v.push_back(x); } cin >> m >> l; for (i = 0; i < m; i++) { cin >> x; v1.push_back(x); } for (i = 0; i < n; i++) { for (j = i + 1; j <= (n - 1); j++) { jha = jha * k; } sum1 = sum1 + jha * v[i]; jha = 1; } for (i = 0; i < m; i++) { for (j = i + 1; j <= (m - 1); j++) { jha = jha * l; } sum2 = sum2 + jha * v1[i]; jha = 1; } if (sum1 > sum2) cout << ">" << endl; else if (sum1 < sum2) cout << "<" << endl; else cout << "=" << endl; return 0; }
7
CPP
#!/usr/bin/env python3 # 602A_mem.py - Codeforces.com/problemset/problem/602/A by Sergey 2015 import unittest import sys ############################################################################### # Mem Class (Main Program) ############################################################################### class Mem: """ Mem representation """ def __init__(self, test_inputs=None): """ Default constructor """ it = iter(test_inputs.split("\n")) if test_inputs else None def uinput(): return next(it) if it else sys.stdin.readline().rstrip() # Reading single elements [self.n, self.bx] = map(int, uinput().split()) # Reading a single line of multiple elements self.numsx = list(map(int, uinput().split())) # Reading single elements [self.m, self.by] = map(int, uinput().split()) # Reading a single line of multiple elements self.numsy = list(map(int, uinput().split())) self.x = 0 for n in self.numsx: self.x = self.x * self.bx + n self.y = 0 for n in self.numsy: self.y = self.y * self.by + n def calculate(self): """ Main calcualtion function of the class """ if self.x == self.y: return "=" if self.x > self.y: return ">" return "<" ############################################################################### # Unit Tests ############################################################################### class unitTests(unittest.TestCase): def test_single_test(self): """ Mem class testing """ # Constructor test test = "6 2\n1 0 1 1 1 1\n2 10\n4 7" d = Mem(test) self.assertEqual(d.n, 6) self.assertEqual(d.m, 2) # Sample test self.assertEqual(Mem(test).calculate(), "=") # Sample test test = "3 3\n1 0 2\n2 5\n2 4" self.assertEqual(Mem(test).calculate(), "<") # Sample test test = "7 16\n15 15 4 0 0 7 10\n7 9\n4 8 0 3 1 5 0" self.assertEqual(Mem(test).calculate(), ">") # My tests test = "" # self.assertEqual(Mem(test).calculate(), "0") # Time limit test # self.time_limit_test(5000) def time_limit_test(self, nmax): """ Timelimit testing """ import random import timeit # Random inputs test = str(nmax) + " " + str(nmax) + "\n" numnums = [str(i) + " " + str(i+1) for i in range(nmax)] test += "\n".join(numnums) + "\n" nums = [random.randint(1, 10000) for i in range(nmax)] test += " ".join(map(str, nums)) + "\n" # Run the test start = timeit.default_timer() d = Mem(test) calc = timeit.default_timer() d.calculate() stop = timeit.default_timer() print("\nTimelimit Test: " + "{0:.3f}s (init {1:.3f}s calc {2:.3f}s)". format(stop-start, calc-start, stop-calc)) if __name__ == "__main__": # Avoiding recursion limitaions sys.setrecursionlimit(100000) if sys.argv[-1] == "-ut": unittest.main(argv=[" "]) # Print the result string sys.stdout.write(Mem().calculate())
7
PYTHON3
#from dust i have come dust i will be n,bx=map(int,input().split()) x=list(map(int,input().split())) m,by=map(int,input().split()) y=list(map(int,input().split())) px=pow(bx,n-1) py=pow(by,m-1) px=int(px) py=int(py) a=0 for i in range(n): a+=(x[i]*px) px//=bx b=0 for i in range(m): b+=(y[i]*py) py//=by #print(a,b) if a==b: print('=') elif a>b: print('>') else: print('<')
7
PYTHON3
q = input().split() n1 = int(q[0]) b1 = int(q[1]) a = input().split() n1 = 0 for i in range(len(a)): a[i] = int(a[i]) n1 = n1 * b1 + a[i] q = input().split() n2 = int(q[0]) b2 = int(q[1]) b = input().split() n2 = 0 for i in range(len(b)): b[i] = int(b[i]) n2 = n2 * b2 + b[i] if n1 < n2: print('<') elif n1 > n2: print('>') else: print('=')
7
PYTHON3
#include <bits/stdc++.h> #pragma GCC optimize("Ofast", "inline", "-ffast-math") #pragma GCC target("abm,avx,mmx,popcnt,sse,sse2,sse3,ssse3,sse4") inline long long read() { long long x = 0, y = 1; long long c = getchar(); while (c < '0' || c > '9') { if (c == '-') y = -1; c = getchar(); } while (c >= '0' && c <= '9') { x = (x << 1) + (x << 3) + (c ^ 48); c = getchar(); } return x * y; } long long l, r, n, m, x, y, num; int main() { n = read(), x = read(); for (int i = 1; i <= n; i++) { num = read(); l = l * x + num; } scanf("%lld%lld", &m, &y); for (int i = 1; i <= m; i++) { num = read(); r = r * y + num; } puts(l == r ? "=" : (l > r ? ">" : "<")); }
7
CPP
#include <bits/stdc++.h> using namespace std; long long l, m, a[11], b, c[11], d, x, y; int main() { cin >> l >> b; for (int i = l - 1; i >= 0; i--) cin >> a[i]; cin >> m >> d; for (int i = m - 1; i >= 0; i--) cin >> c[i]; x = y = 1; for (int i = 0; i < l; i++) { a[i] *= x; x *= b; } for (int i = 0; i < m; i++) { c[i] *= y; y *= d; } b = d = 0; for (int i = 0; i < l; i++) b += a[i]; for (int i = 0; i < m; i++) d += c[i]; if (b < d) cout << "<\n"; else if (b > d) cout << ">\n"; else cout << "=\n"; }
7
CPP
def bases(): n,b=map(int, input().split()) v=0 for x in map(int,input().split()): v=b*v + x return v x,y=bases(),bases() print('<' if x<y else ('>' if x>y else '='))
7
PYTHON3
def perevod(chislo, osnovanie, dlina): rez = 0 for i in range(dlina): rez += chislo[i] * osnovanie**i return rez n, bx = map(int, input().split()) x = list(map(int, input().split())) m, by = map(int, input().split()) y = list(map(int, input().split())) x = x[::-1] y = y[::-1] rez1 = 0 rez2 = 0 rez1 = perevod(x, bx, n) rez2 = perevod(y, by, m) if rez1 == rez2: print('=') elif rez1 < rez2: print('<') else: print('>')
7
PYTHON3
#include <bits/stdc++.h> using namespace std; int abs(int a) { return a < 0 ? -1 * a : a; } void solve() { int n, m, bx, by; cin >> n >> bx; int x[n]; for (int i = 0; i < n; i++) cin >> x[i]; cin >> m >> by; int y[m]; for (int i = 0; i < m; i++) cin >> y[i]; long long X = 0, Y = 0; for (int i = n - 1; i >= 0; i--) { X = X + x[i] * pow(bx, n - i - 1); } for (int i = m - 1; i >= 0; i--) { Y = Y + y[i] * pow(by, m - i - 1); } if (X == Y) { cout << "="; return; } else if (X > Y) { cout << ">"; return; } cout << "<"; return; } int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); ; int t = 1; solve(); return 0; }
7
CPP
cin = lambda:map(int,input().split()) def solve(): n,a = cin() sum=0 for i in cin(): sum=(sum*a+i) return sum ans1,ans2=solve(),solve() print ('>' if ans1>ans2 else '<' if ans1<ans2 else '=')
7
PYTHON3
n,bx = map(int, input().split()) X = list(map(int, input().split())) m,by = map(int, input().split()) Y = list(map(int, input().split())) def calcul(n,bx,X): r = X[n-1] c = 1 for k in range(2,n+1): c *= bx r += X[n-k]*c return r x = calcul(n,bx,X) y = calcul(m,by,Y) if x==y: print("=") elif x>y: print(">") else: print("<")
7
PYTHON3
#!/usr/local/bin/python3.4 -tt import random import sys if __name__ == '__main__': def _(f): for l in f: for i in l.split(): yield int(i) g = _(sys.stdin) n, b = (next(g), next(g), ) X = 0 for i in range(n): X = X * b + next(g) Y = 0 n, b = (next(g), next(g), ) for i in range(n): Y = Y * b + next(g) if X < Y: print('<') elif X > Y: print('>') else: print('=')
7
PYTHON3
#include <bits/stdc++.h> using namespace std; int main() { int digit, base, pos, n; long long int sum = 0, sum_1 = 0, weight; cin >> digit >> base; pos = digit - 1; for (int i = 0; i < digit; i++, pos--) { cin >> n; weight = base; if (pos == 0) weight = 1; for (int j = 1; j < pos; j++) { weight *= base; } sum += n * weight; } cin >> digit >> base; pos = digit - 1; for (int i = 0; i < digit; i++, pos--) { cin >> n; weight = base; if (pos == 0) weight = 1; for (int j = 1; j < pos; j++) { weight *= base; } sum_1 += n * weight; } if (sum == sum_1) cout << "=" << endl; else if (sum > sum_1) cout << ">" << endl; else cout << "<" << endl; return 0; }
7
CPP
n, bx = map(int, input().split()) x = list(map(int, input().split())) m, by = map(int, input().split()) y = list(map(int, input().split())) x = x[::-1] y = y[::-1] st = 1 ansx = 0 for i in range(n): ansx += x[i] * st st *= bx st = 1 ansy = 0 for i in range(m): ansy += y[i] * st st *= by print("=" if ansx == ansy else ("<" if ansx < ansy else ">"))
7
PYTHON3
def get(): n, b = map(int, input().split()) v = 0 for x in map(int, input().split()): v = b * v + x return v x, y = get(), get() print('<' if x < y else ('>' if x > y else '='))
7
PYTHON3
#include <bits/stdc++.h> using namespace std; long long Deci(int arr[], int base, int n) { long long power = 1; long long num = 0; for (int i = n - 1; i >= 0; i--) { num += arr[i] * power; power = power * base; } return num; } int main() { int n, m, x, y; cin >> n >> x; int arr[n + 3]; for (int i = 0; i < n; i++) { cin >> arr[i]; } cin >> m >> y; int brr[m + 3]; for (int i = 0; i < m; i++) { cin >> brr[i]; } long long X = Deci(arr, x, n); long long Y = Deci(brr, y, m); if (X < Y) cout << "<\n"; else if (X > Y) cout << ">\n"; else cout << "=\n"; }
7
CPP
n1, m1 = map(int, input().split()) a1 = list(map(int, input().split())) ans1 = 0 ind1 = n1 - 1 for i in a1: ans1 += i * (m1 ** ind1) ind1 -= 1 n2, m2 = map(int, input().split()) a2= list(map(int, input().split())) ans2 = 0 ind2 = n2 - 1 for i in a2: ans2 += i * (m2 ** ind2) ind2 -= 1 if (ans1 == ans2): print('=') else: if (ans1 > ans2): print('>') else: print('<')
7
PYTHON3
#include <bits/stdc++.h> #pragma GCC optimize("Ofast", "inline", "-ffast-math") #pragma GCC target("avx,sse2,sse3,sse4,mmx") long long l, r, n, m, x, y, num; int main() { scanf("%lld%lld", &n, &x); for (register int i = 1; i <= n; i++) { scanf("%lld", &num); l = l * x + num; } scanf("%lld%lld", &m, &y); for (register int i = 1; i <= m; i++) { scanf("%lld", &num); r = r * y + num; } puts(l == r ? "=" : (l > r ? ">" : "<")); }
7
CPP
n, n1 = map(int,input().split()) a = [int(x) for x in input().split()] m,m1 = map(int,input().split()) b = [int(x) for x in input().split()] s1 = 0 s2 = 0 k = 0 for i in range(len(a)-1,-1,-1): s1 += a[i] * (n1**k) k += 1 k = 0 for i in range(len(b)-1,-1,-1): s2 += b[i] * (m1**k) k += 1 if s1 < s2 : print('<') elif s1 > s2: print('>') else : print('=')
7
PYTHON3
#include <bits/stdc++.h> using namespace std; int b, n; long long hatv(long long alap, long long kitevo) { long long valasz = 1; for (long long i = 1; i <= kitevo; i++) valasz *= alap; return valasz; } long long egyik, masik; int main() { cin >> n >> b; for (int i = 1; i <= n; i++) { long long aktj; cin >> aktj; long long ad = aktj * hatv(b, n - i); egyik += ad; } cin >> n >> b; for (int i = 1; i <= n; i++) { long long aktj; cin >> aktj; long long ad = aktj * hatv(b, n - i); masik += ad; } if (egyik < masik) cout << '<'; else if (egyik > masik) cout << '>'; else cout << '='; return 0; }
7
CPP
def f(nums, base): num = 0 for j in range(len(nums)): num *= base num += nums[j] return num n, b1 = [int(j) for j in input().split()] x = [int(j) for j in input().split()] m, b2 = [int(j) for j in input().split()] y = [int(j) for j in input().split()] n1, n2 = f(x, b1), f(y, b2) if n1 < n2: print('<') elif n1 > n2: print('>') else: print('=')
7
PYTHON3
#include <bits/stdc++.h> using namespace std; long long int n, a, x[10], m, b, y[10], A, B; int main() { cin >> n >> a; long int k = 1; for (int i = 0; i < n; i++) { cin >> x[i]; A = A * a + x[i]; } cin >> m >> b; long int j = 1; for (int i = 0; i < m; i++) { cin >> y[i]; B = B * b + y[i]; } if (A > B) { cout << ">"; } else if (A < B) { cout << "<"; } else { cout << "="; } return 0; }
7
CPP
nx, bx = map(int, input().split(' ')[:2]) xs = list(map(int, input().split(' ')[:nx])) ny, by = map(int, input().split(' ')[:2]) ys = list(map(int, input().split(' ')[:ny])) p = 1 x = 0 for d in reversed(xs): x += d * p p *= bx p = 1 y = 0 for d in reversed(ys): y += d * p p *= by if x == y: print('=') elif x < y: print('<') else: print('>')
7
PYTHON3
import sys a, b = map(int, input().split()) c = list(map(int, input().split())) d, e = map(int, input().split()) f = list(map(int, input().split())) c.reverse() f.reverse() s1 = s2 = 0 for i in range(0, a): s1 += c[i] * (b ** i) for i in range(0, d): s2 += f[i] * (e ** i) if s1 < s2: sys.stdout.write('<') elif s1 > s2: sys.stdout.write('>') else: sys.stdout.write('=')
7
PYTHON3
R = lambda : map(int, input().split()) def get_num(): n,b = R() v = list(R())[::-1] i = 1 num = 0 for _ in range(len(v)): num += i*v[_] i *= b return num x = get_num() y = get_num() if x > y: print(">") elif x == y: print("=") else: print("<")
7
PYTHON3
#include <bits/stdc++.h> using namespace std; int nx, bx, ny, by; int x, y; long long ansx = 0, ansy = 0; int main() { cin >> nx >> bx; for (int i = 0; i < nx; i++) cin >> x, ansx *= bx, ansx += x; cin >> ny >> by; for (int i = 0; i < ny; i++) cin >> y, ansy *= by, ansy += y; if (ansx == ansy) printf("="); if (ansx > ansy) printf(">"); if (ansx < ansy) printf("<"); }
7
CPP
bx = int(input().split()[1]) X = tuple(map(int, input().split())) by = int(input().split()[1]) Y = tuple(map(int, input().split())) x = y = 0 for d in X: x = x * bx + d for d in Y: y = y * by + d if x == y: print('=') elif x > y: print('>') else: print('<')
7
PYTHON3
#!/usr/bin/python3 from itertools import * from collections import Counter from operator import * from functools import reduce import re, math from pprint import pprint from fractions import gcd def sqr(x): return x*x def inputarray(func=int): return map(func, input().split()) # -------------------------------------- # -------------------------------------- x, bx = inputarray() A = reversed(list(inputarray())) X, k = 0, 1 for i, v in enumerate(A): X = X + v*k k = k*bx y, by = inputarray() B = reversed(list(inputarray())) Y, k = 0, 1 for i, v in enumerate(B): Y = Y + v*k k = k*by if X < Y: print('<') elif X > Y: print('>') else: print('=')
7
PYTHON3
a, abase = map(int, input().split()) aval = list(map(int, input().split())) first = 0 for i in range(a): first += aval[i]*abase**(a-1) a-=1 # print(first) b, bbase = map(int, input().split()) bval = list(map(int, input().split())) second = 0 for i in range(b): second += bval[i]*bbase**(b-1) b-=1 # print(second) if(first == second): print("=") elif(first <second): print("<") else: print(">")
7
PYTHON3
#include <bits/stdc++.h> #pragma comment(linker, "/STACK:1677721600") using namespace std; const int mod = 1e9 + 7; const double eps = 1e-8; const double ee = exp(1.0); const int inf = 0x3f3f3f3f; const int maxn = 1e6 + 10; const double pi = acos(-1.0); int readT() { char c; int ret = 0, flg = 0; while (c = getchar(), (c < '0' || c > '9') && c != '-') ; if (c == '-') flg = 1; else ret = c ^ 48; while (c = getchar(), c >= '0' && c <= '9') ret = ret * 10 + (c ^ 48); return flg ? -ret : ret; } long long readTL() { char c; int flg = 0; long long ret = 0; while (c = getchar(), (c < '0' || c > '9') && c != '-') ; if (c == '-') flg = 1; else ret = c ^ 48; while (c = getchar(), c >= '0' && c <= '9') ret = ret * 10 + (c ^ 48); return flg ? -ret : ret; } long long mypow(int a, int t) { long long res = 1; for (int i = (1); i <= (t); i++) { res *= a; } return res; } int main() { int n = readT(); int b1 = readT(); long long ansb1 = 0; for (int i = (0); i <= (n - 1); i++) { long long t = readTL(); ansb1 += t * mypow(b1, n - i - 1); } int n2 = readT(); int b2 = readT(); long long ansb2 = 0; for (int i = (0); i <= (n2 - 1); i++) { long long t = readTL(); ansb2 += t * mypow(b2, n2 - i - 1); } if (ansb1 == ansb2) puts("="); else if (ansb1 < ansb2) puts("<"); else puts(">"); return 0; }
7
CPP
def solve(): n, b = map(int, input().split()) v = 0 for x in map(int, input().split()): v = b * v + x return v x, y = solve(), solve() print('<' if x < y else ('>' if x > y else '='))
7
PYTHON3
def intConvert(l): for i in range(0, len(l)): l[i] = int(l[i]) def base10(l, base): result = 0 for i in range(0, len(l)): result += l[len(l)-i-1]*(base**i) return result d1 = input().split() digits1 = input().split() intConvert(d1) intConvert(digits1) result1 = base10(digits1, d1[1]) d2 = input().split() digits2 = input().split() intConvert(d2) intConvert(digits2) result2 = base10(digits2, d2[1]) if(result1 == result2): print("=") elif(result1 < result2): print("<") elif(result1 > result2): print(">")
7
PYTHON3
#include <bits/stdc++.h> #pragma comment(linker, "/STACK:102400000,102400000") using namespace std; const int INF = 0x3f3f3f3f; const int MAX = 0x7fffffff; const double eps = 1e-9; const double pi = acos(-1.0); const int maxn = 100000 + 5; const int maxm = 100000 + 5; const int mod = 1e9 + 7; int n, m; int bn, bm; long long dn, dm; void indata() { cin >> n >> bn; dn = 0; long long t; for (int i = 1; i <= n; ++i) { cin >> t; dn = dn * bn + t; } cin >> m >> bm; dm = 0; for (int i = 1; i <= m; ++i) { cin >> t; dm = dm * bm + t; } } void slove() { if (dn < dm) { cout << "<" << endl; } else if (dn == dm) { cout << "=" << endl; } else { cout << ">" << endl; } } int main() { { indata(); slove(); } return 0; }
7
CPP
#include <bits/stdc++.h> using namespace std; int main() { int size1, base1, size2, base2; cin >> size1 >> base1; int num1[size1]; for (int i = 0; i < size1; i++) cin >> num1[i]; cin >> size2 >> base2; int num2[size2]; for (int i = 0; i < size2; i++) cin >> num2[i]; long long int base_temp = 1; long long int num1_end = 0; for (int i = size1 - 1; i > -1; i--) { num1_end += num1[i] * base_temp; base_temp *= base1; } base_temp = 1; long long int num2_end = 0; for (int i = size2 - 1; i > -1; i--) { num2_end += num2[i] * base_temp; base_temp *= base2; } if (num1_end > num2_end) cout << ">"; else if (num1_end < num2_end) cout << "<"; else cout << "="; return 0; }
7
CPP
a , A = map(int,input().split()) t = list(map(int,input().split()))[::-1] b,B = map(int,input().split()) y = list(map(int,input().split()))[::-1] h=0 for j in range(a): h+=t[j]*((A)**j) g=0 for i in range(b): g+=y[i]*(B**i) if h>g: print('>') elif g>h: print('<') else: print('=')
7
PYTHON3
#include <bits/stdc++.h> using namespace std; int main() { long long int t, n, k, i, c; cin >> n >> k; long long int num = 0, num1 = 0; for (i = 0; i < n; i++) { cin >> c; int power = n - 1 - i; t = k; while (power > 1) { k = k * t; power--; } if (i == n - 1) k = 1; num += c * k; k = t; } cin >> n >> k; for (i = 0; i < n; i++) { cin >> c; int power = n - i - 1; t = k; while (power > 1) { k = k * t; power--; } if (i == n - 1) k = 1; num1 += c * k; k = t; } if (num > num1) cout << ">"; else if (num < num1) cout << "<"; else cout << "="; return 0; }
7
CPP
#include <bits/stdc++.h> using namespace std; int main() { int digitx; cin >> digitx; int basex; cin >> basex; unsigned long long int x = 0; for (int i = digitx - 1; i >= 0; i--) { int v; cin >> v; x += v * pow(basex, i); } int digity; cin >> digity; int basey; cin >> basey; unsigned long long int y = 0; for (int i = digity - 1; i >= 0; i--) { int v; cin >> v; y += v * pow(basey, i); } if (x == y) cout << "=\n"; else if (x > y) cout << ">\n"; else if (x < y) cout << "<\n"; }
7
CPP
bx=int(input().split()[1]) x=list(map(int,input().split())) by=int(input().split()[1]) y=list(map(int,input().split())) X=Y=0 for xi in x: X=X*bx+xi for yi in y: Y=Y*by+yi if(X>Y): print(">") elif(X<Y): print("<") else: print("=")
7
PYTHON3
#include <bits/stdc++.h> int main() { double bx[10], by[10], n, i, x, y, mx, my; scanf("%lf%lf", &n, &x); n = n - 1; for (int i = 0; i <= n; i++) { scanf("%lf", &bx[i]); } mx = 0; my = 0; for (int i = 0; i <= n; i++) { mx = mx + bx[i] * pow(x, (n - ((float)i))); } scanf("%lf%lf", &n, &y); n = n - 1; for (int i = 0; i <= n; i++) { scanf("%lf", &by[i]); } for (int i = 0; i <= n; i++) { my = my + by[i] * pow(y, (n - ((float)i))); } if (my == mx) { printf("="); } if (my < mx) { printf(">"); } if (my > mx) { printf("<"); } }
7
CPP
#include <bits/stdc++.h> int main() { std::ios::sync_with_stdio(false); std::cin.tie(nullptr); size_t n; int64_t bx; std::cin >> n >> bx; int64_t X = 0; for (size_t i = 0; i < n; ++i) { int64_t x; std::cin >> x; X = X * bx + x; } size_t m; int64_t by; std::cin >> m >> by; int64_t Y = 0; for (size_t i = 0; i < m; ++i) { int64_t y; std::cin >> y; Y = Y * by + y; } if (X < Y) { std::cout << '<'; } else if (X > Y) { std::cout << '>'; } else { std::cout << '='; } std::cout << '\n'; }
7
CPP
i=input() n,bx= tuple(map(int,i.split(' '))) i=input() val1=sum([int(a)*(bx**(n-ind-1)) for ind,a in enumerate(i.split(' '))]) i=input() n,bx= tuple(map(int,i.split(' '))) i=input() val2=sum([int(a)*(bx**(n-ind-1)) for ind,a in enumerate(i.split(' '))]) #print(val1) #print(val2) if val1==val2: print('=') else: if(val1<val2): print('<') else: print('>')
7
PYTHON3
f=[int(i) for i in input().split()] x=[int(i) for i in input().split()] s=[int(i) for i in input().split()] y=[int(i) for i in input().split()] bx=f.pop() nx=f.pop() by=s.pop() ny=s.pop() xreal=0 yreal=0 if bx==10: xreal='' for num in x: xreal+=str(num) xreal=int(xreal) else: k=len(x) count=1 for num in x: xreal+=num*(bx**(k-count)) count+=1 if by==10: yreal='' for num in y: yreal+=str(num) yreal=int(yreal) else: k=len(y) count=1 for num in y: yreal+=num*(by**(k-count)) count+=1 if xreal==yreal: print('=') elif xreal>yreal: print('>') else: print('<')
7
PYTHON3
#include <bits/stdc++.h> using namespace std; template <class T> inline void umax(T &a, T b) { if (a < b) a = b; } template <class T> inline void umin(T &a, T b) { if (a > b) a = b; } const int N = 2e5; long long X, Y, x[N], y[N]; long long nx, bx; long long ny, by; long long basx, basy; int main() { cin >> nx >> bx; for (int i = 1; i <= nx; i++) cin >> x[i]; cin >> ny >> by; for (int i = 1; i <= ny; i++) cin >> y[i]; basx = basy = 1; for (int i = nx; i >= 1; i--) { X += basx * x[i]; basx *= bx; } for (int i = ny; i >= 1; i--) { Y += basy * y[i]; basy *= by; } if (X < Y) cout << '<'; else if (X > Y) cout << '>'; else cout << '='; return !1; }
7
CPP
nx,x=[int(i) for i in input().split()] X=0 for i in input().split(): X+=int(i)*x**(nx-1) nx-=1 ny,y=[int(i) for i in input().split()] Y=0 for i in input().split(): Y+=int(i)*y**(ny-1) ny-=1 if X<Y: print('<') elif X>Y: print('>') else: print('=')
7
PYTHON3
z1 = list(map(int,input().split())) x = list(map(int,input().split())) z2 = list(map(int,input().split())) y= list(map(int,input().split())) n1, b1 = z1[0],z1[1] n2, b2 = z2[0],z2[1] ansx = ansy = 0 for i in range(n1): ansx+= x[n1-i-1]*(b1**i) for i in range(n2): ansy+= y[n2-i-1]*(b2**i) if ansx == ansy: print('=') elif ansx > ansy: print('>') else: print('<')
7
PYTHON3
#include <bits/stdc++.h> using namespace std; int n, b, tmp; long long num(0), num1; long long Get() { for (cin >> n >> b, num = 0; n--; cin >> tmp, num = num * b + tmp) ; return num; } int main() { char ans[] = {'=', '<', '>'}; num1 = Get(); num = Get(); cout << ans[(num1 < num) + (num1 > num) * 2]; return 0; }
7
CPP
n, b = map(int, input().split()) x = 0 l = list(map(int, input().split())) for i in range(n): x = b*x + l[i] n, b = map(int, input().split()) y = 0 l = list(map(int, input().split())) for i in range(n): y = b*y + l[i] if x < y: print("<") elif x == y: print("=") else: print(">")
7
PYTHON3
def func(x,arr): arr=list(map(int,arr)) arr.reverse() num=0 b=1 for i in arr: num=num+(b*i) b=b*x return num inp=input().split() inp=list(map(int,inp)) n,m=inp arr=input().split() n1=func(m,arr) inp=input().split() inp=list(map(int,inp)) n,m=inp arr=input().split() n2=func(m,arr) if(n1<n2): print ('<') elif n1==n2: print ('=') else : print ('>')
7
PYTHON3
def get_value(): num_digits, base = map(int, input().split()) value = 0 for digit in map(int, input().split()): value = base * value + digit return value x, y = get_value(), get_value() if x < y: print('<') elif x > y: print('>') else: print('=')
7
PYTHON3
#include <bits/stdc++.h> using namespace std; int main() { unsigned long long sum1 = 0, sum2 = 0, fact = 1; int n, m, k, b1, b2; vector<int> arr1, arr2; cin >> n >> b1; for (int i = n - 1; i >= 0; i--) { cin >> k; arr1.push_back(k); } cin >> m >> b2; for (int i = m - 1; i >= 0; i--) { cin >> k; arr2.push_back(k); } for (int i = n - 1; i >= 0; i--) { sum1 += (arr1[i] * fact); fact *= b1; } fact = 1; for (int i = m - 1; i >= 0; i--) { sum2 += (arr2[i] * fact); fact *= b2; } if (sum1 > sum2) { cout << ">" << endl; } else if (sum1 < sum2) { cout << "<" << endl; } else { cout << "=" << endl; } return 0; }
7
CPP
#include <bits/stdc++.h> using namespace std; void A(); void B(); void C(); void D(); void E(); int main() { A(); return 0; } long long compute(int n, int bx) { long long a = 0; int x[n]; for (int i = 0; i < n; i++) { scanf("%d", &x[i]); } long long base = 1; for (int i = n - 1; i >= 0; i--) { a += base * x[i]; base *= bx; } return a; } void A() { int n, bx, m, by; scanf("%d %d", &n, &bx); long long a = compute(n, bx); scanf("%d %d", &m, &by); long long b = compute(m, by); printf("%s\n", a == b ? "=" : a < b ? "<" : ">"); }
7
CPP
#include <bits/stdc++.h> using namespace std; long long power(long long a, long long b) { long long f = 1; for (long long i = 1; i <= b; i++) { f *= a; } return f; } long long n, bx; long long x, sum1 = 0; long long m, by; long long y, sum2 = 0; int main() { ios_base::sync_with_stdio(false); cin.tie(); ; cin >> n >> bx; for (long long i = 1; i <= n; i++) { cin >> x; sum1 += x * power(bx, n - i); } cin >> m >> by; for (long long i = 1; i <= m; i++) { cin >> y; sum2 += y * power(by, m - i); } if (sum1 == sum2) { cout << "="; } else if (sum1 > sum2) { cout << ">"; } else { cout << "<"; } return 0; }
7
CPP
n,a=input().split() n=int(n) x=0 p=1 a=int(a) l=input().split() for i in range(n): x+=int(l[n-i-1])*p p*=a n,b=input().split() n=int(n) y=0 p=1 b=int(b) l=input().split() for i in range(n): y+=int(l[n-i-1])*p p*=b if(x==y): print("=") elif(x<y): print("<") else: print(">")
7
PYTHON3
n, base = map(int, input().split()) a = [int(i) for i in input().split()] chislo1 = 0 for i in range(n): chislo1 += a[i]*(base**(n-i-1)) n, base = map(int, input().split()) a = [int(i) for i in input().split()] chislo2 = 0 for i in range(n): chislo2 += a[i]*(base**(n-i-1)) if chislo2 > chislo1: print('<') elif chislo2 == chislo1: print('=') else: print('>')
7
PYTHON3
#include <bits/stdc++.h> using namespace std; int main() { unsigned long long n, bx, p1 = 1, s1 = 0; cin >> n >> bx; unsigned long long x[n]; for (int i = 0; i < n; i++) cin >> x[i]; for (int i = n - 1; i >= 0; i--) { s1 += x[i] * p1; p1 *= bx; } unsigned long long m, by, p2 = 1, s2 = 0; cin >> m >> by; unsigned long long y[m]; for (int i = 0; i < m; i++) cin >> y[i]; for (int i = m - 1; i >= 0; i--) { s2 += y[i] * p2; p2 *= by; } if (s1 > s2) cout << ">" << endl; else if (s1 < s2) cout << "<" << endl; else cout << "=" << endl; return 0; }
7
CPP
def func(): n, b = map(int, input().split()) v = 0 for i in map(int, input().split()): v = b * v + i return v x, y = func(), func() print('<' if x < y else ('>' if x > y else '='))
7
PYTHON3
n,bx = [int(i) for i in input().split()] x = [int(i) for i in input().split()] m,by = [int(i) for i in input().split()] y = [int(i) for i in input().split()] xd,yd = 0,0 for i in range(n):xd+=x[i]*bx**(n-i-1) for i in range(m):yd+=y[i]*by**(m-i-1) if xd<yd: print('<') elif xd>yd: print('>') else: print('=')
7
PYTHON3
n,x=map(int,input().split()) bx=list(input().split()) m,y=map(int,input().split()) by=list(input().split()) nx=0 p=n-1 for i in bx: nx += ((x**p)*int(i)) p -= 1 p=m-1 my=0 for i in by: my += ((y**p)*int(i)) p -= 1 #print(nx) #print(my) if nx<my: print("<") if nx>my: print(">") if nx==my: print("=")
7
PYTHON3
#include <bits/stdc++.h> using namespace std; template <typename... T> void r(T&... args) { ((cin >> args), ...); } template <typename... T> void w(T&&... args) { ((cout << args << " "), ...); } template <typename T> void disp(T arr) { for (long long i = 0; i < arr.size(); i++) { cout << arr[i] << " "; } cout << endl; } void solve() { long long n, m, x, temp = 0, sum1 = 0, sum2 = 0, cnt = 0, in, i, j, k, flag = 1; string s, s1, s2; vector<int> v, e, o, p; long long b1, b2; r(n, b1); for (i = 0; i < n; i++) { r(in); v.push_back(in); } k = 0; r(m, b2); for (i = k; i < m; i++) { r(in); p.push_back(in); } i = 1; temp = 0; reverse(v.begin(), v.end()); reverse(p.begin(), p.end()); while (temp < v.size()) { sum1 += v[temp] * i; temp++; i *= b1; } temp = 0; i = 1; while (temp < p.size()) { sum2 += p[temp] * i; temp++; i *= b2; } if (sum1 > sum2) cout << ">"; else if (sum1 < sum2) cout << "<"; else cout << "="; } int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); long long t = 1; while (t--) solve(); return 0; }
7
CPP
#include <bits/stdc++.h> using namespace std; unsigned long long todec(string s, int osn) { unsigned long long ans = 0; for (int i = 0; i < s.size(); ++i) { ans = osn * ans + s[i] - '0'; } return ans; } int main() { int n, osn1, m, osn2; string a = "", b = ""; scanf("%d%d", &n, &osn1); for (int i = 0; i < n; ++i) { int x; scanf("%d", &x); a += x + '0'; } scanf("%d%d", &m, &osn2); for (int i = 0; i < m; ++i) { int x; scanf("%d", &x); b += x + '0'; } unsigned long long x = todec(a, osn1); unsigned long long y = todec(b, osn2); if (x == y) { printf("="); } else if (x < y) { printf("<"); } else printf(">"); }
7
CPP
#include <bits/stdc++.h> using namespace std; long long pow(int a, int n) { long long sum = 1; for (int i = 1; i <= n; i++) sum *= a; return sum; } long long to10(int a[], int n, int d) { int k = 0; long long sum = 0; while (n--) { sum += a[n] * pow(d, k); k++; } return sum; } int a, b, s[1008611]; int main() { ios::sync_with_stdio(false); int a[11], n, d; while (cin >> n >> d) { for (int i = 0; i < n; i++) cin >> a[i]; long long A = to10(a, n, d); cin >> n >> d; for (int i = 0; i < n; i++) cin >> a[i]; long long B = to10(a, n, d); if (A < B) cout << "<" << endl; else if (A > B) cout << ">" << endl; else cout << "=" << endl; } return 0; }
7
CPP
x, n = map(int, input().split()) a = 0 for e in map(int, input().split()): a += e a *= n a //= n x, n = map(int, input().split()) b = 0 for e in map(int, input().split()): b += e b *= n b //= n if a < b: print('<') elif a > b: print('>') else: print('=')
7
PYTHON3
#include <bits/stdc++.h> using namespace std; long long read() { long long n, x, ans = 0; cin >> n >> x; for (long long i = 0; i < n; ++i) { long long t; cin >> t; ans *= x; ans += t; } return ans; } int main() { long long n = read(); long long m = read(); if (n < m) cout << "<\n"; else if (n == m) cout << "=\n"; else cout << ">\n"; }
7
CPP
n, bx = input().split() n = int(n) bx = int(bx) x = 0 for i in input().split(): x = x*bx + int(i) m, by = input().split() m = int(m) by = int(by) y = 0 for i in input().split(): y = y*by + int(i) if x == y: print('=') elif x>y: print('>') else: print('<')
7
PYTHON3
def getIn10bySt(n, st): m = 0 ans = 0 i = len(n)-1 while i >= 0: ans += int(n[i]) * (st**m) m+=1 i-=1 return ans n, x = list(map(int, input().split())) a = list(map(int, input().split())) X = getIn10bySt(a, x) n, x = list(map(int, input().split())) a = list(map(int, input().split())) Y = getIn10bySt(a, x) if X > Y: print(">") elif X < Y: print("<") else: print("=")
7
PYTHON3