s_id stringlengths 10 10 | p_id stringlengths 6 6 | u_id stringlengths 10 10 | date stringlengths 10 10 | language stringclasses 1
value | original_language stringclasses 11
values | filename_ext stringclasses 1
value | status stringclasses 1
value | cpu_time stringlengths 1 5 | memory stringlengths 1 7 | code_size stringlengths 1 6 | code stringlengths 1 539k |
|---|---|---|---|---|---|---|---|---|---|---|---|
s380750038 | p03963 | u996284376 | 1512900630 | Python | Python (3.4.3) | py | Runtime Error | 17 | 2940 | 153 | #include <stdio.h>
#include <math.h>
int main(void) {
int a, b, ans;
scanf("%d %d",&a, &b);
printf("%d",(b*(int)pow((double)(b-1),(double)(a-1))));
} |
s812280202 | p03963 | u405509847 | 1478405241 | Python | Python (3.4.3) | py | Runtime Error | 22 | 3068 | 79 | N, K = map(int, raw_input().split())
# N, K = 10, 8
print (K * (K-1) ** (N-1)) |
s028689545 | p03963 | u272496669 | 1477844426 | Python | Python (3.4.3) | py | Runtime Error | 23 | 3064 | 94 | list = input().split()
a = bin(int(list[0])-1)
b = int(list[1])-1
print(pow(b,a)*int(list[1])) |
s372357795 | p03963 | u083668616 | 1477622847 | Python | Python (2.7.6) | py | Runtime Error | 48 | 3520 | 181 | def exp(x, n):
if n == 0:
return 1
else:
return x * exp(x, n-1)
def main():
inpt = raw_input().split()
n = int(inpt[0])
k = int(inpt[1])
print k * exp(k-1, n-1)
main()
|
s710703985 | p03963 | u731028462 | 1476675968 | Python | Python (3.4.2) | py | Runtime Error | 24 | 3064 | 329 | n, m = list(map(int, input().split()))
a = [input() for i in range(n)]
print(n,m)
##
## Template
##
## map, filter, reduce
# map(lambda x: x*2, range(10))
# filter(lambda x: x % 2, range(10))
# from functools import reduce
# reduce(lambda sum,x: sum+x, range(10))
# [x * 2 for x in range(1, 10) if x % 3 == 1]
# => [2... |
s994846045 | p03963 | u729300713 | 1476582644 | Python | Python (2.7.6) | py | Runtime Error | 16 | 2568 | 257 | import sys
n, k = map(int, raw_input().split())
ans = k # first
if n = 1 and k = 1:
print ans
sys.exit()
for i in range(n-1):
ans *= k-1
print ans
|
s064851493 | p03963 | u729300713 | 1476582607 | Python | Python (2.7.6) | py | Runtime Error | 16 | 2568 | 248 | import sys
n, k = map(int, raw_input().split())
ans = k # first
if n = 1 and k = 1:
print ans
sys.exit()
for i in range(n-1):
ans *= k-1
|
s348719510 | p03963 | u442810826 | 1476581396 | Python | Python (2.7.6) | py | Runtime Error | 16 | 2568 | 104 | K = raw_input().split()
N=int(N)
K=int(K)
if N==1:
print K
else:
A = K*pow(K-1,N-1)
print A
|
s721911247 | p03963 | u442810826 | 1476581344 | Python | Python (3.4.3) | py | Runtime Error | 24 | 3064 | 107 |
N,K = raw_input().split()
N=int(N)
K=int(K)
if N==1:
print K
else:
A = K*pow(K-1,N-1)
print A
|
s613843470 | p03963 | u442810826 | 1476581216 | Python | Python (3.4.3) | py | Runtime Error | 21 | 3064 | 107 |
N,K = raw_input().split()
N=int(N)
K=int(K)
if N==1:
print K
else:
A = K*pow(K-1,N-1)
print A
|
s199105175 | p03964 | u648315264 | 1601065890 | Python | PyPy3 (7.3.0) | py | Runtime Error | 118 | 68572 | 1005 | import math
from math import gcd,pi,sqrt
INF = float("inf")
MOD = 10**9 + 7
import sys
sys.setrecursionlimit(10**6)
import itertools
import bisect
from collections import Counter,deque
def i_input(): return int(input())
def i_map(): return map(int, input().split())
def i_list(): return list(i_map())
def i_row(N): retu... |
s160975742 | p03964 | u825685913 | 1600884000 | Python | Python (3.8.2) | py | Runtime Error | 26 | 9196 | 324 | import math
n = int(input())
A, B = 0, 0
for i in range(n):
x, y = int(input.split())
dx, dy = 1, 1
if A > x:
dx = A // x
if A % x != 0:
dx += 1
if B > y:
dy = B // y
if B % y != 0:
dy += 1
a = max(dx, dy)
A, B = a * x, a * y
print(A ... |
s074512407 | p03964 | u748241164 | 1592942902 | Python | PyPy3 (7.3.0) | py | Runtime Error | 216 | 79952 | 640 | import fractions
N = int(input())
for i in range(N):#1000
t, a = map(int, input().split())
if i == 0:
taka, aoki = t, a
else:
now = [10 ** 10, -1, -1]
for i in range(1001):
if ((taka + i) * (a / t)) % 1 == 0:
a2 = int((taka + i) * (a / t))
if (now[0] >= a2 + taka + i) and (a2 >... |
s130746901 | p03964 | u102367647 | 1592575275 | Python | Python (3.8.2) | py | Runtime Error | 116 | 26936 | 1270 | import sys
import numpy as np
import random
import math
from decimal import Decimal
import itertools
import re
import bisect
from collections import deque, Counter
from functools import lru_cache
sys.setrecursionlimit(10**9)
INF = 10**13
def LI(): return list(map(int, sys.stdin.buffer.readline().split()))
def I(): ret... |
s664716685 | p03964 | u312078744 | 1591853934 | Python | Python (3.4.3) | py | Runtime Error | 36 | 5088 | 429 | import math
from fractions import Fraction
n = int(input())
x, y = map(int, input().split())
t, a = x, y
for _ in range(n - 1):
tt, aa = map(int, input().split())
#c = 1
'''
if (t >= a):
c = math.ceil(tt / t)
else:
c = math.ceil(aa / a)
'''
#c = math.ceil(t / tt, a / aa)
... |
s919740094 | p03964 | u029000441 | 1591739649 | Python | PyPy3 (2.4.0) | py | Runtime Error | 164 | 38384 | 1320 | # coding: utf-8
# hello worldと表示する
import sys
import numpy
input = sys.stdin.readline
sys.setrecursionlimit(10**7)
from collections import Counter, deque
from collections import defaultdict
from itertools import combinations, permutations, accumulate, groupby, product
from bisect import bisect_left,bisect_right
from he... |
s113971099 | p03964 | u308918401 | 1591316578 | Python | Python (3.4.3) | py | Runtime Error | 18 | 3064 | 264 | import math
n=int(input())
x,y=map(int,input().split())
gcd=math.gcd(x,y)
x=int(x/gcd)
y=int(y/gcd)
for i in range(n-1):
s,t=map(int,input().split())
if s<x:
w=int(x/s)+1
s*=w
t*=w
if t<y:
w=int(y/t)+1
s*=w
t*=w
x=s
y=t
print(x+y) |
s580394855 | p03964 | u935077683 | 1590864913 | Python | Python (3.4.3) | py | Runtime Error | 18 | 3064 | 228 | from math import gcd, ceil
n = int(input())
a, b = 1, 1
for _ in range(n):
x, y = map(int, input().split())
xx, yy = (ceil(a / x) * x, ceil(b / y) * y)
f = max(xx // x, yy // y)
a, b = f * x, f * y
print(a + b)
|
s021070782 | p03964 | u935077683 | 1590863831 | Python | Python (3.4.3) | py | Runtime Error | 17 | 3064 | 282 | from math import gcd, ceil
n = int(input())
a, b = map(int, input().split())
g = gcd(a, b)
a //= g
b //= g
for _ in range(n - 1):
x, y = map(int, input().split())
xx, yy = (ceil(a / x) * x, ceil(b / y) * y)
f = max(xx // x, yy // y)
a, b = f * x, f * y
print(a + b) |
s070262538 | p03964 | u935077683 | 1590863431 | Python | Python (3.4.3) | py | Runtime Error | 18 | 3064 | 315 | from math import *
n = int(input())
a, b = map(int, input().split())
g = gcd(a, b)
a //= g
b //= g
for _ in range(n - 1):
x, y = map(int, input().split())
x //= gcd(x, y)
y //= gcd(x, y)
xx, yy = (ceil(a / x) * x, ceil(b / y) * y)
f = max(xx // x, yy // y)
a, b = f * x, f * y
print(a + b)
|
s190897837 | p03964 | u405256066 | 1590369718 | Python | Python (3.4.3) | py | Runtime Error | 18 | 3064 | 299 | from sys import stdin
import math
N = int(stdin.readline().rstrip())
t,a = [int(x) for x in stdin.readline().rstrip().split()]
for _ in range(N-1):
T,A = [int(x) for x in stdin.readline().rstrip().split()]
int(n) = max(math.ceil(t/T),math.ceil(a/A))
t = n*T
a = n*A
print(t+a) |
s047603790 | p03964 | u792512290 | 1589741442 | Python | Python (3.4.3) | py | Runtime Error | 17 | 3064 | 332 | n = int(input())
ary = []
for i in range(n):
tmp_ary = list(map(int, input().split()))
if len(ary) == 0:
ary = tmp_ary[:]
else:
t_rate = math.ceil(ary[0] / tmp_ary[0])
a_rate = math.ceil(ary[1] / tmp_ary[1])
rate = max([t_rate, a_rate])
ary = list(map(lambda x: x * rate, tmp_ary))
print(ary[0... |
s170956528 | p03964 | u513081876 | 1589650753 | Python | Python (3.4.3) | py | Runtime Error | 19 | 3188 | 352 | N = int(input())
TA = [[int(i) for i in input().split()] for i in range(N)]
Takahashi, Aoki = TA[0][0], TA[0][1]
for ta, ao in TA:
if Takahashi <= ta and Aoki <= ao:
Takahashi, Aoki = ta, ao
else:
num = max(math.ceil(Takahashi / ta), math.ceil(Aoki / ao))
Takahashi, Aoki = num * ta, num... |
s162303940 | p03964 | u127499732 | 1589488090 | Python | Python (3.4.3) | py | Runtime Error | 18 | 3060 | 276 | def main():
from math import ceil
n = int(input())
a, b = 1, 1
for _ in range(n):
i, j = map(int, input().split())
x = max((a + s - 1) // s, (b + t - 1) // t)
a, b = x * i, x * j
print(a + b)
if __name__ == '__main__':
main()
|
s777056538 | p03964 | u287132915 | 1588818229 | Python | Python (3.4.3) | py | Runtime Error | 20 | 3064 | 886 | import math
def lcm_base(x, y):
return (x * y) // math.gcd(x, y)
n = int(input())
t_lst, a_lst = [], []
for i in range(n):
ti, ai = map(int, input().split())
t_lst.append(ti)
a_lst.append(ai)
t, a = 1, 1
for i in range(n):
ti, ai = t_lst[i], a_lst[i]
if ti>=t and ai>=a:
t, a = ti, ai
... |
s018744870 | p03964 | u287132915 | 1588818096 | Python | Python (3.4.3) | py | Runtime Error | 20 | 3064 | 892 | import math
def lcm_base(x, y):
return (x * y) // math.gcd(x, y)
n = int(input())
t_lst, a_lst = [], []
for i in range(n):
ti, ai = map(int, input().split())
t_lst.append(ti)
a_lst.append(ai)
t, a = 1, 1
for i in range(n):
ti, ai = t_lst[i], a_lst[i]
if ti>=t and ai>=a:
t, a = ti, ai
... |
s644317656 | p03964 | u287132915 | 1588817353 | Python | Python (3.4.3) | py | Runtime Error | 19 | 3064 | 776 | import math
def lcm_base(x, y):
return (x * y) // math.gcd(x, y)
n = int(input())
t, a = 1, 1
for i in range(n):
ti, ai = map(int, input().split())
if ti>=t and ai>=a:
t, a = ti, ai
elif ti<t and ai>=a:
t = ti * math.ceil(t/ti)
a = ai * math.ceil(t/ti)
elif ti>=t and ai<a:
... |
s963874872 | p03964 | u423665486 | 1588438535 | Python | PyPy3 (2.4.0) | py | Runtime Error | 200 | 39280 | 239 | def resolve():
n = int(input())
v = []
for _ in range(n):
v.append(list(map(int, input().split())))
t, a = 1, 1
for i in range(n):
tv, av = v[i]
c = max(math.ceil(t/tv), math.ceil(a/av))
t, a = c*tv, c*av
print(t+a)
resolve() |
s322874776 | p03964 | u423665486 | 1588438373 | Python | PyPy3 (2.4.0) | py | Runtime Error | 241 | 39280 | 254 | def resolve():
n = int(input())
v = []
for _ in range(n):
v.append(list(map(int, input().split())))
t, a = v[0][0], v[0][1]
for i in range(1, n):
tv, av = v[i]
c = max(math.ceil(t/tv), math.ceil(a/av))
t, a = c*tv, c*av
print(t+a)
resolve() |
s401791776 | p03964 | u934868410 | 1587430443 | Python | Python (3.4.3) | py | Runtime Error | 21 | 3060 | 187 | import math
n = int(input())
A,B = map(int,input().split())
for _ in range(n-1):
a,b = map(int,input().split())
m = max(math.ceil(A/a), math.ceil(B/b))
A,B = A * m, B * m
print(A+B) |
s276471622 | p03964 | u934868410 | 1587430414 | Python | Python (3.4.3) | py | Runtime Error | 17 | 3060 | 175 | n = int(input())
A,B = map(int,input().split())
for _ in range(n-1):
a,b = map(int,input().split())
m = max(math.ceil(A/a), math.ceil(B/b))
A,B = A * m, B * m
print(A+B) |
s295348045 | p03964 | u556610039 | 1583331942 | Python | Python (3.4.3) | py | Runtime Error | 17 | 2940 | 284 | import math
n = int(input())
ans = 0
t_1, a_1 = map(int, input().split())
pret = t_1
prea = a_1
for x in range(n - 1):
t, a = map(int, input().split())
else:
m = max(math.ceil(pret / t), math.ceil(prea / a))
pret = m * t
prea = m * a
print(pret + prea) |
s838151169 | p03964 | u620157187 | 1582619800 | Python | Python (3.4.3) | py | Runtime Error | 25 | 3700 | 328 | import math
from functools import reduce
N = int(input())
t = [0] * N
A = [0] * N
total = []
for i in range(N):
t[i], A[i] = map(int, input().split())
total.append(t[i]+A[i])
def lcm_base(x, y):
return (x * y) // math.gcd(x, y)
def lcm_list(numbers):
return reduce(lcm_base, numbers, 1)
print(lcm_list... |
s950874418 | p03964 | u052221988 | 1582422156 | Python | Python (3.4.3) | py | Runtime Error | 1633 | 22328 | 914 | import numpy as np
n = int(input())
vlist = [input().split() for i in range(n)]
for m in range(n) :
vlist[m] = [int(l) for l in vlist[m]]
for j in range(n-1) :
if vlist[j][0] <= vlist[j+1][0] and vlist[j][1] <= vlist[j][1] :
continue
if vlist[j][0] > vlist[j+1][0] and vlist[j][0] > vlist[j][1] :
... |
s413760209 | p03964 | u052221988 | 1582422024 | Python | Python (3.4.3) | py | Runtime Error | 20 | 3316 | 895 | n = int(input())
vlist = [input().split() for i in range(n)]
for m in range(n) :
vlist[m] = [int(l) for l in vlist[m]]
for j in range(n-1) :
if vlist[j][0] <= vlist[j+1][0] and vlist[j][1] <= vlist[j][1] :
continue
if vlist[j][0] > vlist[j+1][0] and vlist[j][0] > vlist[j][1] :
vlist[j+1] = [... |
s189299201 | p03964 | u052221988 | 1582421987 | Python | Python (3.4.3) | py | Runtime Error | 18 | 3064 | 772 | for j in range(n-1) :
if vlist[j][0] <= vlist[j+1][0] and vlist[j][1] <= vlist[j][1] :
continue
if vlist[j][0] > vlist[j+1][0] and vlist[j][0] > vlist[j][1] :
vlist[j+1] = [int(k*(np.lcm(vlist[j][0], vlist[j+1][0]))/vlist[j+1][0]) for k in vlist[j+1]]
continue
elif vlist[j][1] > vlis... |
s092733794 | p03964 | u941753895 | 1578287083 | Python | Python (3.4.3) | py | Runtime Error | 18 | 2940 | 760 | https://atcoder.jp/contests/abc046/tasks/arc062_a
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,queue,copy
sys.setrecursionlimit(10**7)
inf=10**20
mod=10**9+7
dd=[(-1,0),(0,1),(1,0),(0,-1)]
ddn=[(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]
def LI(): return [int(x) ... |
s853909654 | p03964 | u906428167 | 1577416083 | Python | PyPy3 (2.4.0) | py | Runtime Error | 171 | 38384 | 249 | n = int(input())
from math import ceil, gcd
tkhs = 1
aoki = 1
for _ in range(n):
t, a = map(int, input().split())
t, a = t // gcd(t,a), a // gcd(t,a)
k = max(ceil(tkhs/t), ceil(aoki/a))
tkhs = k*t
aoki = k*a
print(tkhs+aoki)
|
s591010511 | p03964 | u710659690 | 1577181084 | Python | PyPy3 (2.4.0) | py | Runtime Error | 165 | 38452 | 216 | import numpy as np
N = int(input())
ans1 = 1
ans2 = 1
for _ in range(N):
i1, i2 = list(map(int, input().split()))
n = max(np.ceil(ans1/i1), np.ceil(ans2/i2))
ans1 = i1 * n
ans2 = i2 * n
print(int(ans1+ans2)) |
s589038754 | p03964 | u716530146 | 1576982938 | Python | Python (3.4.3) | py | Runtime Error | 19 | 3188 | 186 | def ceil(x,y):
return x//y+(not( not x%y))
n=int(input())
a,b=1,1
for i in range(n):
t,s = map(int,input().split())
i = max( ceil(a/t), ceil(b/s) )
a=t*i;b=s*i
print(a+b) |
s461624541 | p03964 | u716530146 | 1576963000 | Python | Python (3.4.3) | py | Runtime Error | 19 | 3188 | 252 | from math import ceil
# def ceil(x,y):
# return (x-1)//y+1
N = int(input())
TA = [list(map(int, input().split())) for _ in range(N)]
t, a = 1, 1
for T, A in TA:
rate = max(ceil(t, T), ceil(a, A))
t = T * rate
a = A * rate
print(t + a)
|
s166218640 | p03964 | u716530146 | 1576962405 | Python | Python (3.4.3) | py | Runtime Error | 20 | 3188 | 213 | from math import ceil
N = int(input())
TA = [list(map(int, input().split())) for _ in range(N)]
t, a = 1, 1
for T, A in TA:
rate = max(ceil(t, T), ceil(a, A))
t = T * rate
a = A * rate
print(t + a)
|
s048653337 | p03964 | u923659712 | 1572694199 | Python | Python (3.4.3) | py | Runtime Error | 19 | 3064 | 268 | n=int(input())
t=[0]*n
a=[0]*n
for i in range(n):
t,a=map(int,input().split())
for i in range(n-1):
while (t[i]>t[i+1]) or (a[i]>a[i+1]):
for k in range(1,100000000000000000000000000000000):
t[i+1]*=k
a[i+1]*=k
print(a[n]+t[n]) |
s225800430 | p03964 | u886747123 | 1571426681 | Python | Python (3.4.3) | py | Runtime Error | 21 | 3188 | 463 | # C - AtCoDeerくんと選挙速報 / AtCoDeer and Election Report
# 比がa:bとなる合計最小の票分布はa,b
# 次にc:dになったとき、a<=cかつb<=dとなるようにc,dに同じ数をかける
import math
N = int(input())
TA = [list(map(int, input().split())) for _ in range(N)]
a, b = TA[0]
for idx in range(1,N):
c, d = TA[idx]
multi = max(math.ceil(a/c), math.ceil(b/d))
c *=... |
s113272521 | p03964 | u595716769 | 1570686948 | Python | Python (3.4.3) | py | Runtime Error | 17 | 2940 | 30 | 5
3 10
48 17
31 199
231 23
3 2 |
s434776632 | p03964 | u780962115 | 1569162591 | Python | Python (3.4.3) | py | Runtime Error | 40 | 5432 | 431 | #greedy方法
import fractions
n=int(input())
lists=[]
for x in range(n):
x,y=map(int,input().split())
lists.append([x,y])
lists.append([1,1])
a=lists[0][0]
b=lists[0][1]
k=0
cnt=0
while cnt<n:
k=max(fractions.ceil(a/lists[cnt+1][0]),fractions.ceil(b/lists[cnt+1][1]))
a=lists[cnt+1][0]*k
b=lists[cnt+1][... |
s142128199 | p03964 | u252828980 | 1568830391 | Python | Python (3.4.3) | py | Runtime Error | 21 | 3064 | 444 | n = int(input())
a,b = map(int,input().split())
for i in range(n-1):
c,d = map(int,input().split())
if (c>=a and d>=b):
a = c
b = d
elif not(c>=a and d>=b):
if a%c != 0:
e = a//c+1
elif a%c == 0:
e = a//c
if b%d != 0:
f = b//d+1
... |
s676722563 | p03964 | u252828980 | 1568828553 | Python | Python (3.4.3) | py | Runtime Error | 2103 | 3064 | 500 | n = int(input())
a,b = map(int,input().split())
for i in range(n-1):
c,d = map(int,input().split())
if (c>=a and d>=b):
a = c
b = d
if not(c>=a and d>=b):
#print(not(c>=a and d>=b))
#print(c,d)
k,l = c,d
m = 1
while True:
#print(c,d)
... |
s643901421 | p03964 | u759412327 | 1568173536 | Python | Python (3.4.3) | py | Runtime Error | 17 | 2940 | 191 | N = int(input())
t = 0
a = 0
for _iin range(N):
rt,ra = map(int,input().split())
c = max((t-1)//rt+1,(a-1)//ra+1)
t = rt*c
a = ra*c
if a+t == 0:
t += rt
a += ra
print(a+t) |
s806981738 | p03964 | u759412327 | 1568081052 | Python | Python (3.4.3) | py | Runtime Error | 17 | 3060 | 191 | N = int(input())
t = 0
a = 0
for _ in range(N):
rt,ra = map(int,input().split())
c = max((t-1)//rt+1 (a-1)//ra+1)
t = rt*c
a = ra*c
if a+t == 0:
t += rt
a += ra
print(a+t) |
s691480446 | p03964 | u433532588 | 1567134197 | Python | Python (3.4.3) | py | Runtime Error | 17 | 2940 | 1 | x |
s598015482 | p03964 | u626337957 | 1565781971 | Python | Python (3.4.3) | py | Runtime Error | 17 | 3060 | 348 | N = int(input())
T, A = map(int, input().split())
num = T + A
for _ in range(N-1):
t, a = map(int, input().split())
while True:
if num%(t+a) == 0 and (num*t)//(t+a) >= T and (num*a)//(t+a) >= A:
T = (num*t)//(t+a)
A = (num*a)//(t+a)
break
if num%(t+a) == 0
num += num
else:
... |
s723869875 | p03964 | u084324798 | 1565369582 | Python | Python (3.4.3) | py | Runtime Error | 17 | 2940 | 344 | num = int(input())
arr = [list(map(int, input().split())) for i in range(num)]
ans = [[arr[0][0], arr[0][1]]
for i in range(num-1):
ans.append([arr[i+1][0], arr[i+1][1]])
while ans[i][0] > ans[i+1][0] or ans[i][1] > ans[i+1][1]:
ans[i+1][0] += arr[i+1][0]
ans[i+1][1] += arr[i+1][1]
print(ans[nu... |
s620925739 | p03964 | u626337957 | 1565292192 | Python | Python (3.4.3) | py | Runtime Error | 17 | 3060 | 194 | N = int(input())
num = 1
for _ in range(N):
x, y = map(int, input().split())
sum_xy = sum(x, y)
while True:
if num%sum_xy == 0:
break
else:
num += num%sum_xy
print(num) |
s885160342 | p03964 | u172111219 | 1563914394 | Python | PyPy3 (2.4.0) | py | Runtime Error | 233 | 40944 | 287 | if __name__ =="__main__":
n = int(input())
ls = [[int(x) for x in input().split()] for _ in range(n)]
now_t,now_a = ls[0]
for i in range(1,n):
x = max([~-now_t/ls[i][0] +1 ,~-now_a/ls[i][1] +1])
now_t,now_a = x*ls[i][0],x*ls[i][1]
print(now_t+now_a) |
s693902363 | p03964 | u172111219 | 1563914330 | Python | PyPy3 (2.4.0) | py | Runtime Error | 212 | 40048 | 285 | if __name__ =="__main__":
n = int(input())
ls = [[int(x) for x in input().split()] for _ in range(n)]
now_t,now_a = ls[0]
for i in range(1,n):
x = max([~-now_t/ls[i][0]+1 ,~-now_a/ls[i][1]+1])
now_t,now_a = x*ls[i][0],x*ls[i][1]
print(now_t+now_a) |
s700803530 | p03964 | u567434159 | 1562989835 | Python | Python (3.4.3) | py | Runtime Error | 17 | 2940 | 187 | from math import gcd
a, b = 1, 1
for _ in range(int(input())):
x, y = map(int, input().split())
k = int(max((a + x - 1) // x, (b + y - 1) // y))
a = x * k
b = y * k
print(a + b)
|
s195995775 | p03964 | u567434159 | 1562989805 | Python | Python (3.4.3) | py | Runtime Error | 17 | 2940 | 187 | from math import gcd
a, b = 1, 1
for _ in range(int(input())):
x, y = map(int, input().split())
k = int(max((a + x - 1) // x, (b + y - 1) // y))
a = x * k
b = y * k
print(a + b)
|
s428122140 | p03964 | u567434159 | 1562989631 | Python | Python (3.4.3) | py | Runtime Error | 17 | 3060 | 199 | from math import gcd
from math import ceil
a, b = 1, 1
for _ in range(int(input())):
x, y = map(int, input().split())
k = int(max(ceil(x / a), ceil(y / b)))
a = x * k
b = y * k
print(a + b)
|
s934610944 | p03964 | u567434159 | 1562989604 | Python | Python (3.4.3) | py | Runtime Error | 17 | 3060 | 209 | from math import gcd
from math import ceil
a, b = 1, 1
for _ in range(int(input())):
x, y = map(int, input().split())
k = int(max(math.ceil(x / a), math.ceil(y / b)))
a = x * k
b = y * k
print(a + b)
|
s472516242 | p03964 | u567434159 | 1562988591 | Python | Python (3.4.3) | py | Runtime Error | 17 | 2940 | 135 | from math import gcd
rs = 1
for _ in range(int(input())):
x = sum(map(int, input().split()))
rs = x * rs / gcd(x, rs)
print(rs)
|
s504210987 | p03964 | u474423089 | 1562295100 | Python | Python (3.4.3) | py | Runtime Error | 2104 | 3444 | 666 | from collections import deque
def main():
n = int(input())
t = []
a = []
for i in range(n):
in_t,in_a = map(int,input().split(' '))
t.append(in_t)
a.append(in_a)
q= deque()
q.append([t[0],a[0]])
for i in range(1,n):
while True:
tmp_t,tmp_a=q.pople... |
s903541145 | p03964 | u223646582 | 1561658921 | Python | Python (3.4.3) | py | Runtime Error | 36 | 5048 | 203 | import fractions
N=int(input())
t,a=1,1
for i in range(N):
T,A=map(int,input().split())
# n=max(-(-a//A),-(-t//T))
n=max(fractions.ceil(a/A),fractions.ceil(t/T))
t,a=n*T,n*A
print(t+a)
|
s215110176 | p03964 | u223646582 | 1561651200 | Python | PyPy3 (2.4.0) | py | Runtime Error | 296 | 63980 | 172 | import fractions
N=int(input())
t,a=1,1
for i in range(N):
T,A=map(int,input().split())
n=max(fractions.ceil(a/A),fractions.ceil(t/T))
t,a=n*T,n*A
print(t+a)
|
s993008987 | p03964 | u704001626 | 1560230101 | Python | Python (3.4.3) | py | Runtime Error | 20 | 3188 | 370 | # -*- coding: utf-8 -*-
n = int(input())
ta = [list(map(int,input().split())) for i in range(n)]
cur_t = 1
cur_a = 1
def ceil(a, b):
return a // b + int(a % b != 0)
for t,a in ta:
if cur_t > t or cur_a > a:
rate = ceil(max([cur_t/t,cur_a/a]))
cur_t = t*rate
cur_a = a*rate
else:
... |
s091385862 | p03964 | u655834330 | 1556562805 | Python | PyPy3 (2.4.0) | py | Runtime Error | 202 | 38768 | 548 |
import math
def read_input():
n = int(input())
ratios = []
for i in range(n):
t, a = map(int, input().split())
ratios.append((t, a))
return n, ratios
def get_votes(ex_votes, ratio):
base = max(math.ceil(ex_votes[0]/ratio[0]), math.ceil(ex_votes[1]/ratio[1]))
return (base * ... |
s238918815 | p03964 | u037430802 | 1554525450 | Python | Python (3.4.3) | py | Runtime Error | 17 | 2940 | 272 | import math
n = int(input())
pt = [0] * n
pa = [0] * n
for i in range(n):
t, a = map(int, input().split())
if i == 0:
pt[0] = t
pa[0] = a
else:
tmp = math.ceil(max(pt[i-1]/, pa[i-1]/a))
pt[i]=tmp*t
pa[i]=tmp*a
print(int(pt[-1] + pa[-1])) |
s749496527 | p03964 | u037430802 | 1554525430 | Python | Python (3.4.3) | py | Runtime Error | 17 | 2940 | 274 | import math
n = int(input())
pt = [0] * n
pa = [0] * n
for i in range(n):
t, a = map(int, input().split())
if i == 0:
pt[0] = t
pa[0] = a
else:
tmp = math.ceil(max(pt[i-1]/t*, pa[i-1]/a))
pt[i]=tmp*t
pa[i]=tmp*a
print(int(pt[-1] + pa[-1])) |
s619944907 | p03964 | u037430802 | 1554525033 | Python | Python (3.4.3) | py | Runtime Error | 18 | 2940 | 282 | import math
n = int(input())
pt = [0] * n
pa = [0] * n
for i in range(n):
t, a = map(int, input().split())
if i == 0:
pt[0] = t
pa[0] = a
else:
tmp = math.ceil(max([pt[i-1]/t*1.0, pa[i-1]a*1.0]))
pt[i]=tmp*t
pa[i]=tmp*a
print(int(pt[-1] + pa[-1])) |
s118671673 | p03964 | u026155812 | 1554247443 | Python | Python (3.4.3) | py | Runtime Error | 38 | 5144 | 493 | import sys
import math
import bisect
import heapq
import copy
from fractions import gcd
from itertools import permutations, combinations,combinations_with_replacement,product
from collections import defaultdict, Counter, deque
N = int(input())
T, A = [0]*N, [0]*N
for i in range(N):
T[i], A[i] = map(int, input().sp... |
s596954251 | p03964 | u026155812 | 1554246204 | Python | Python (3.4.3) | py | Runtime Error | 22 | 2940 | 527 | import sys
import math
import bisect
import heapq
import copy
from fractions import gcd
from itertools import permutations, combinations,combinations_with_replacement,product
from collections import defaultdict, Counter, deque
N = int(input())
T, A = [0]*N, [0]*N
for i in range(N):
T[i], A[i] = map(int, input().sp... |
s125581178 | p03964 | u001024152 | 1553281853 | Python | Python (3.4.3) | py | Runtime Error | 18 | 2940 | 243 | N = int(input())
ratio = [tuple(map(int, input().split())) for _ in range(N)]
t,a = 1,1
for nt,na in ratio:
if nt<t or na<a:
r = max(-(-t//nt), -(-a//na)
nt *= r
na *= r
t,a = nt,na
#print(t, a)
print(t+a)
|
s410359592 | p03964 | u001024152 | 1553279017 | Python | PyPy3 (2.4.0) | py | Runtime Error | 216 | 39536 | 288 | from math import ceil
N = int(input())
ratio = [tuple(map(int, input().split())) for _ in range(N)]
t,a = 1,1
for nt,na in ratio:
r = 1
if nt<t:
r *= ceil(t/nt)
if na*r<a:
r *= ceil(a/na)
na = r*na
nt = r*nt
t,a = nt,na
#print(t, a)
print(t+a) |
s255489824 | p03964 | u001024152 | 1553278676 | Python | Python (3.4.3) | py | Runtime Error | 20 | 3188 | 286 | from math import ceil
N = int(input())
ratio = [tuple(map(int, input().split())) for _ in range(N)]
t,a = 1,1
for nt,na in ratio:
r = 1
if nt<t:
r *= ceil(t/nt)
if na<a:
r *= ceil(a/na)
na = r*na
nt = r*nt
t,a = nt,na
#print(t, a)
print(t+a) |
s031530386 | p03964 | u518064858 | 1551507494 | Python | Python (3.4.3) | py | Runtime Error | 22 | 3064 | 349 | n=int(input())
for i in range(n):
if i==0:
x,y=map(int,input().split())
else:
t,a=map(int,input().split())
if t==1 and a==1:
x=max(x,y)
y=max(x,y)
else:
t=t*max(int(x/t),int(y/a))
a=a*max(int(x/t),int(y/a))
x=t
... |
s971689172 | p03964 | u518064858 | 1551504753 | Python | Python (3.4.3) | py | Runtime Error | 18 | 3060 | 258 | n=int(input())
for i in range(n):
if i==1:
x,y=map(int,input().split())
else:
t,a=map(int,input().split())
v=t
w=a
while t<x or a<y:
v+=t
w+=a
x=v
y=w
print(x+y)
|
s966800604 | p03964 | u964763428 | 1551328001 | Python | Python (3.4.3) | py | Runtime Error | 17 | 2940 | 433 | #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
int N;
cin >> N;
vector<ll> T(N);
vector<ll> A(N);
for (int i = 0; i < N; i++) {
cin >> T.at(i) >> A.at(i);
}
ll t=1,a=1;
for (int i = 0; i < N; i++) {
ll x=t/T.at(i);
ll y=a/A.at(i);
if(t%T.at(i)!=0) x++;... |
s312978946 | p03964 | u369752439 | 1548108316 | Python | Python (3.4.3) | py | Runtime Error | 22 | 3188 | 953 | from math import *
N = int(input())
T = []
A = []
for i in range(0, N):
ti, ai = [int(x) for x in input().split()]
T.append(ti)
A.append(ai)
prevT = T[0]
prevA = A[0]
for i in range(1, N):
nextfacT = int(ceil(prevT / T[i]))
nextfacA = int(ceil(prevA / A[i]))
nextfac = max(nextfacT, nextfacA)
... |
s461979673 | p03964 | u575431498 | 1547686087 | Python | Python (3.4.3) | py | Runtime Error | 17 | 3064 | 393 | A = []
for _ in range(N):
t, a = map(int, input().split())
T.append(t)
A.append(a)
curT = T[0]
curA = A[0]
for i in range(1, N):
if curT > curA:
if curT % T[i] != 0:
curT += T[i] - curT % T[i]
curA = curT // T[i] * A[i]
else:
if curA % A[i] != 0:
curA ... |
s385447184 | p03964 | u343930666 | 1547294441 | Python | Python (3.4.3) | py | Runtime Error | 18 | 2940 | 1359 | #include <iostream>
#include <cmath>
#include <vector>
#include <string>
#include <algorithm>
#include <numeric>
#include <queue>
typedef long long ll;
const ll INF = 1e18 + 1;
const ll MOD = 1e9 + 7;
template<typename T> T lminimum(const std::vector< T >& v) {return *std::min_element(v.begin(), v.end());}
template<t... |
s095353751 | p03964 | u499966353 | 1545580334 | Python | Python (3.4.3) | py | Runtime Error | 22 | 3188 | 408 | n = int(input())
rates = [list(map(int, input().split())) for i in range(n)]
def nextgen(points, nextrate):
pro = 0
boolnow = True
while(boolnow):
pro += 1
boolnow = not(poits[0] <= pro * nextrate[0] and points[1] <= pro * nextrate[1])
return [nextrate[0] * pro, nextrate[1] * pro]
pointnow = [1, 1]
f... |
s554682445 | p03964 | u557437077 | 1545090490 | Python | Python (3.4.3) | py | Runtime Error | 23 | 3060 | 517 | import math
n = int(input())
vote = [0, 0]
# 最初の得票は、最小値を目指すので
# 単純に入力比をそのまま使用
# 各入力に対し、vote[0]<=t*k, vote[1]<=a*kとなる
# 最小のt*k,a*kでvoteを更新
vote = [1, 1]
for i in range(n):
t, a = [int(i) for i in input().split()]
k = max(math.ceil(vote[0] / t), math.ceil(vote[1] / a))
vote = [t * k, a * k]
if sum(vote) ... |
s422311421 | p03964 | u513081876 | 1544894227 | Python | Python (3.4.3) | py | Runtime Error | 21 | 3064 | 443 | from math import ceil
N = int(input())
ta, ao = 1, 1
for i in range(N):
T, A = map(int, input().split())
if ta <= T and ao <= A:
ta = T
ao = A
else:
if ta % T == 0:
n = ta//T
else:
n == ta//T + 1
if ao % A == 0:
m = ao//A
e... |
s426940192 | p03964 | u513081876 | 1543170927 | Python | Python (3.4.3) | py | Runtime Error | 21 | 3060 | 311 | N = int(input())
T, A = 1, 1
for i in range(N):
t, a = map(int, input().split())
if T % t == 0:
n1 = T // t
else:
n1 = T // t + 1
if A % a == 0:
n2 = A // a
else:
n2 = T // a + 1
n = max(n1, n2)
#print(T,A)
T = n*t
A = n*a
print(sum(T+A)) |
s306280147 | p03964 | u060392346 | 1542887254 | Python | Python (3.4.3) | py | Runtime Error | 17 | 2940 | 320 | import math
n = int(input())
ratio = [list(map(int, input().split())) for i in range(n)]
k = 1
for i in range(n-1):
k1 = math.ceil(ratio[i][0] * k / ratio[i+1][0])
k2 = math.ceil(ratio[i][1] * k / ratio[i+1][1])
k3 = math.ceil(sum(ratio[i]) * k / sum(ratio[i+1])
k = max(k1, k2, k3)
print(sum(ratio[n-1]) * k) |
s234469751 | p03964 | u140251125 | 1542814582 | Python | Python (3.4.3) | py | Runtime Error | 30 | 3828 | 368 | from functools import reduce
import math
# input
N = int(input())
TA = [list(map(int, input().split())) for _ in range(N)]
# 最小公倍数
def lcm_base(x, y):
return (x * y) // math.gcd(x, y)
ans = 1
for i in range(N):
if TA[i][0] + TA[i][1] >= ans:
ans = TA[i][0] + TA[i][1]
else:
ans = lcm_base(... |
s993037216 | p03964 | u681150536 | 1540318515 | Python | Python (3.4.3) | py | Runtime Error | 18 | 3064 | 490 | import math
from Decimal import *
def main():
N = int(input())
T = []
A = []
for _ in range(N):
t, a = map(int, input().split())
T.append(t)
A.append(a)
for i in range(N - 1):
if T[i] / T[i + 1] > 1 or A[i] / A[i + 1] > 1:
mul = Decimal(max(math.ceil(T[i... |
s884804046 | p03964 | u681150536 | 1540274872 | Python | Python (3.4.3) | py | Runtime Error | 20 | 3064 | 814 | import math
def main():
N = int(input())
T = []
A = []
for i in range(N):
t, a = map(int, input().split())
T.append(t)
A.append(a)
for i in range(N):
if math.gcd(A[i], T[i]) != 1:
A[i] = A[i] // math.gcd(A[i], T[i])
T[i] = T[i] // math.gcd(A... |
s580798749 | p03964 | u761989513 | 1536899431 | Python | Python (3.4.3) | py | Runtime Error | 18 | 3188 | 255 | def ceil(x, y):
if x % y == 0:
return x // y
else:
return x // y + 1
n = int(input())
t = a = 1
for i in range(n):
T, A = map(int, input().split())
n = max(ceil(t / T), ceil(a / A))
t = n * T
a = n * A
print(t + a) |
s086876154 | p03964 | u466105944 | 1536863985 | Python | Python (3.4.3) | py | Runtime Error | 21 | 3060 | 254 | def ceil(x,y):
if x%y == 0:
return x//y
if x%y == 1:
return x//y + 1
n = int(input())
x,y = 1,1
for _ in range(n):
t,a = map(int,input().split())
temp = max(ceil(x,t),ceil(y,a))
x = t*temp
y = a*temp
print(x+y) |
s938079301 | p03964 | u255280439 | 1535087142 | Python | Python (3.4.3) | py | Runtime Error | 41 | 4852 | 3768 | import sys
import math
import collections
import itertools
import array
import inspect
# Set max recursion limit
sys.setrecursionlimit(1000000)
# Debug output
def chkprint(*args):
names = {
id(v): k
for k, v in inspect.currentframe().f_back.f_locals.items()
}
print(', '.join(
name... |
s525995661 | p03964 | u826263061 | 1534020082 | Python | Python (3.4.3) | py | Runtime Error | 17 | 3064 | 410 | # -*- coding: utf-8 -*-
"""
Created on Sat Aug 11 14:44:47 2018
ABC046C
@author: maezawa
"""
import math
n = int(input())
tp = 1
ap = 1
for i in range(n):
t, a = list(map(int, input().split()))
if ti == t and ai == a:
continue
ti = t
ai = a
nit = tp/ti
nia = ap/ai
ni = math.ceil(max(... |
s736574718 | p03964 | u826263061 | 1534019532 | Python | Python (3.4.3) | py | Runtime Error | 22 | 3064 | 468 | # -*- coding: utf-8 -*-
"""
Created on Sat Aug 11 14:44:47 2018
ABC046C
@author: maezawa
"""
import math
n = int(input())
ti, ai = list(map(int, input().split()))
vp = ti + ai
tp = ti
ap = ai
for i in range(1,n):
t, a = list(map(int, input().split()))
if ti == t and ai == a:
continue
ti = t
ai =... |
s843931820 | p03964 | u826263061 | 1534019418 | Python | Python (3.4.3) | py | Runtime Error | 22 | 3064 | 501 | # -*- coding: utf-8 -*-
"""
Created on Sat Aug 11 14:44:47 2018
ABC046C
@author: maezawa
"""
import math
n = int(input())
ti, ai = list(map(int, input().split()))
vp = ti + ai
tp = ti
ap = ai
for i in range(1,n):
t, a = list(map(int, input().split()))
if ti == t and ai == a:
continue
ti = t
ai =... |
s349138037 | p03964 | u826263061 | 1534018459 | Python | Python (3.4.3) | py | Runtime Error | 22 | 3188 | 563 | # -*- coding: utf-8 -*-
"""
Created on Sat Aug 11 14:44:47 2018
ABC046C
@author: maezawa
"""
import math
n = int(input())
ti, ai = list(map(int, input().split()))
vp = ti + ai
tp = ti
ap = ai
for i in range(1,n):
t, a = list(map(int, input().split()))
if ti == t and ai == a:
continue
ti = t
ai =... |
s649440113 | p03964 | u826263061 | 1534018353 | Python | Python (3.4.3) | py | Runtime Error | 22 | 3064 | 506 | # -*- coding: utf-8 -*-
"""
Created on Sat Aug 11 14:44:47 2018
ABC046C
@author: maezawa
"""
import math
n = int(input())
ti, ai = list(map(int, input().split()))
vp = ti + ai
tp = ti
ap = ai
for i in range(1,n):
t, a = list(map(int, input().split()))
if ti == t and ai == a:
continue
ti = t
ai =... |
s996624530 | p03964 | u826263061 | 1534016876 | Python | Python (3.4.3) | py | Runtime Error | 23 | 3064 | 494 | # -*- coding: utf-8 -*-
"""
Created on Sat Aug 11 14:44:47 2018
ABC046C
@author: maezawa
"""
import math
n = int(input())
ti, ai = list(map(int, input().split()))
vp = ti + ai
tp = ti
ap = ai
for i in range(1,n):
t, a = list(map(int, input().split()))
if ti == t and ai == a:
continue
ti = t
ai =... |
s433189630 | p03964 | u826263061 | 1534016421 | Python | Python (3.4.3) | py | Runtime Error | 22 | 3064 | 429 | # -*- coding: utf-8 -*-
"""
Created on Sat Aug 11 14:44:47 2018
ABC046C
@author: maezawa
"""
import math
n = int(input())
ti, ai = list(map(int, input().split()))
vp = ti + ai
tp = ti
ap = ai
for i in range(1,n):
ti, ai = list(map(int, input().split()))
niv = vp/(ti+ai)
nit = tp/ti
nia = ap/ai
ni = ... |
s146672585 | p03964 | u826263061 | 1534014986 | Python | Python (3.4.3) | py | Runtime Error | 22 | 3064 | 451 | # -*- coding: utf-8 -*-
"""
Created on Sat Aug 11 14:44:47 2018
ABC046C
@author: maezawa
"""
import math
n = int(input())
ti, ai = list(map(int, input().split()))
vp = ti + ai
tp = ti
ap = ai
for i in range(1,n):
ti, ai = list(map(int, input().split()))
niv = math.ceil(vp/(ti+ai))
nit = math.ceil(tp/ti)
... |
s218140839 | p03964 | u826263061 | 1534014593 | Python | Python (3.4.3) | py | Runtime Error | 2108 | 3064 | 444 | # -*- coding: utf-8 -*-
"""
Created on Sat Aug 11 14:44:47 2018
ABC046C
@author: maezawa
"""
import math
n = int(input())
ti, ai = list(map(int, input().split()))
vp = ti + ai
tp = ti
ap = ai
for i in range(1,n):
ti, ai = list(map(int, input().split()))
ni = math.ceil(vp/(ti+ai))
while ni*ti < tp:
n... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.