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 int64 0 100 | memory stringlengths 4 6 | code_size int64 15 14.7k | code stringlengths 15 14.7k | problem_id stringlengths 6 6 | problem_description stringlengths 358 9.83k | input stringlengths 2 4.87k | output stringclasses 807
values | __index_level_0__ int64 1.1k 1.22M |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
s322496074 | p00901 | u260980560 | 1507897402 | Python | Python3 | py | Accepted | 60 | 7904 | 3,532 | MOD = 2011
while 1:
n = int(input())
if n == 0:
break
S = [input() for i in range(n)]
w = len(S[0])
def parse(bcur, bright, top, bottom):
#print("parse", bcur, bright, top, bottom)
base = -1
for i in range(bcur, bright):
for j in range(top, bottom+1):
... | p00901 |
<H1><font color="#000">Problem H: </font>ASCII Expression</H1>
<p>
Mathematical expressions appearing in old papers and old technical articles are printed with typewriter in several lines, where a fixed-width or monospaced font is required to print characters (digits, symbols and spaces). Let us consider the followin... | 4
........4...2..........
(.1.-.----.)..*.-.5.+.6
........2..............
.......3...............
3
...3.
-.---
...4.
4
.3.+.4.*.-.2.
-------------
..........2..
...-.1.-.2...
2
...2..3
(.4..).
1
2.+.3.*.5.-.7.+.9
1
(.2.+.3.).*.(.5.-.7.).+.9
3
.2....3.
4..+.---
......5.
3
.2......-.-.3.
4..-.-.-------
..........5...
9
... | 501
502
1
74
19
2010
821
821
1646
148
81
1933
| 25,136 |
s671080712 | p00914 | u731235119 | 1422156620 | Python | Python | py | Accepted | 80 | 4248 | 312 | while 1:
n, k, s = map(int,raw_input().split())
if (n, k, s) == (0, 0, 0):
break
dp = [[0 for i in range(s)] for j in range(k)]
ub = min(n+1,s+1)
for x in range(1,ub):
for j in range(k-1):
for i in range(s-x):
if dp[j+1][i] >= 1:
dp[j][i+x] += dp[j+1][i]
dp[k-1][x-1] = 1
print dp[0][s-1] | p00914 |
<H1><font color="#000">Problem A: </font>Equal Sum Sets</H1>
<p>
Let us consider sets of positive integers less than or equal to <var>n</var>. Note that all elements of a set are different. Also note that the order of elements doesn't matter, that is, both {3, 5, 9} and {5, 9, 3} mean the same set.
</p>
<p>
Specifyi... | 9 3 23
9 3 22
10 3 28
16 10 107
20 8 102
20 10 105
20 10 155
3 4 3
4 2 11
0 0 0
| 1
2
0
20
1542
5448
1
0
0
| 25,137 |
s288642276 | p00914 | u260980560 | 1552919021 | Python | Python3 | py | Accepted | 40 | 7292 | 375 | memo = {}
def dfs(N, K, S):
key = (N, K, S)
if key in memo:
return memo[key]
if N == 0:
return S == K == 0
r = dfs(N-1, K, S)
if S >= N:
r += dfs(N-1, K-1, S-N)
memo[key] = r
return r
ans = []
while 1:
N, K, S = map(int, input().split())
if N == 0:
br... | p00914 |
<H1><font color="#000">Problem A: </font>Equal Sum Sets</H1>
<p>
Let us consider sets of positive integers less than or equal to <var>n</var>. Note that all elements of a set are different. Also note that the order of elements doesn't matter, that is, both {3, 5, 9} and {5, 9, 3} mean the same set.
</p>
<p>
Specifyi... | 9 3 23
9 3 22
10 3 28
16 10 107
20 8 102
20 10 105
20 10 155
3 4 3
4 2 11
0 0 0
| 1
2
0
20
1542
5448
1
0
0
| 25,138 |
s736260773 | p00915 | u633068244 | 1424443949 | Python | Python | py | Accepted | 90 | 4252 | 516 | while 1:
n,l = map(int,raw_input().split())
if n == 0: break
R = [0]*(l-1)
L = [0]*(l-1)
for i in xrange(1,n+1):
d,p = raw_input().split()
p = int(p)-1
if d == "R": R[p] = i
else: L[p] = i
t = num = 0
while sum(R)+sum(L) != 0:
if R[-1] > 0: num = R[-1]... | p00915 |
<H1><font color="#000">Problem B: </font>The Last Ant</H1>
<p>
A straight tunnel without branches is crowded with busy ants coming and going. Some ants walk left to right and others right to left. All ants walk at a constant speed of 1 cm/s. When two ants meet, they try to pass each other. However, some sections of t... | 3 6
R 1
L 2
L 5
1 10
R 1
2 10
R 5
L 7
2 10
R 3
L 8
2 99
R 1
L 98
4 10
L 1
R 2
L 8
R 9
6 10
R 2
R 3
L 4
R 6
L 7
L 8
0 0
| 5 1
9 1
7 1
8 2
98 2
8 2
8 3
| 25,139 |
s060956051 | p00915 | u509278866 | 1528774944 | Python | Python3 | py | Accepted | 60 | 9040 | 2,017 | import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools
sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**10
mod = 998244353
dd = [(0,-1),(1,0),(0,1),(-1,0)]
ddn = [(0,-1),(1,-1),(1,0),(1,1),(0,1),(-1,-1),(-1,0),(-1,1)]
def LI(): return [int(x) for x in sys.stdi... | p00915 |
<H1><font color="#000">Problem B: </font>The Last Ant</H1>
<p>
A straight tunnel without branches is crowded with busy ants coming and going. Some ants walk left to right and others right to left. All ants walk at a constant speed of 1 cm/s. When two ants meet, they try to pass each other. However, some sections of t... | 3 6
R 1
L 2
L 5
1 10
R 1
2 10
R 5
L 7
2 10
R 3
L 8
2 99
R 1
L 98
4 10
L 1
R 2
L 8
R 9
6 10
R 2
R 3
L 4
R 6
L 7
L 8
0 0
| 5 1
9 1
7 1
8 2
98 2
8 2
8 3
| 25,140 |
s530980865 | p00915 | u260980560 | 1552920313 | Python | Python3 | py | Accepted | 30 | 5616 | 1,312 | import sys
readline = sys.stdin.readline
LR = "LR".index
def solve(A, L):
K = len(A)
if K == 0:
return -1, -1, -1
T = []
v = -1; last = None
left = 0
for i in range(K):
di, pi, ki = A[i]
for j in range(i+1, K):
dj, pj, kj = A[j]
if di > dj:
... | p00915 |
<H1><font color="#000">Problem B: </font>The Last Ant</H1>
<p>
A straight tunnel without branches is crowded with busy ants coming and going. Some ants walk left to right and others right to left. All ants walk at a constant speed of 1 cm/s. When two ants meet, they try to pass each other. However, some sections of t... | 3 6
R 1
L 2
L 5
1 10
R 1
2 10
R 5
L 7
2 10
R 3
L 8
2 99
R 1
L 98
4 10
L 1
R 2
L 8
R 9
6 10
R 2
R 3
L 4
R 6
L 7
L 8
0 0
| 5 1
9 1
7 1
8 2
98 2
8 2
8 3
| 25,141 |
s020134198 | p00924 | u827448139 | 1420839029 | Python | Python3 | py | Accepted | 40 | 6752 | 474 | def read():
return list(map(int,input().split()))
def calc(bs,ls,first):
if sum(ls[0::2])!=bs.count(first) or sum(ls[1::2])!=bs.count(1-first):
return float("inf")
res=0
i,j=0,0
for k in range(0,len(ls),2):
if k>0: i+=ls[k-1]
for _ in range(ls[k]):
j=bs.index(first,j)
res+=abs(j-i)
... | p00924 |
<script type="text/x-mathjax-config">
MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }});
</script>
<script type='text/javascript' src='http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML'></script>
</script>
<h2>Problem A:
Bit String Reorderi... | 6 3
1 0 0 1 0 1
1 3 2
| 1
| 25,142 |
s494306112 | p00924 | u633068244 | 1424439970 | Python | Python | py | Accepted | 20 | 4288 | 590 | N,M = map(int,raw_input().split())
B = map(int,raw_input().split())
P = map(int,raw_input().split())
C1,C2 = [],[]
for i in xrange(M):
C1 += [1]*P[i] if i%2 else [0]*P[i]
C2 += [0]*P[i] if i%2 else [1]*P[i]
ans = 1e10
for C in [C1,C2]:
if sum(B) == sum(C):
tmp = 0
i = j = 0
while no... | p00924 |
<script type="text/x-mathjax-config">
MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }});
</script>
<script type='text/javascript' src='http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML'></script>
</script>
<h2>Problem A:
Bit String Reorderi... | 6 3
1 0 0 1 0 1
1 3 2
| 1
| 25,143 |
s032853960 | p00924 | u260980560 | 1512751837 | Python | Python3 | py | Accepted | 20 | 5600 | 512 | N, M = map(int, input().split())
*B, = map(int, input().split())
*P, = map(int, input().split())
def solve(v):
C = B[:]
D = []
for i in range(M):
D += [(i & 1) ^ v]*P[i]
res = 0
for i in range(N):
if C[i] != D[i]:
for j in range(i, N):
if D[i] == C[j]:
... | p00924 |
<script type="text/x-mathjax-config">
MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }});
</script>
<script type='text/javascript' src='http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML'></script>
</script>
<h2>Problem A:
Bit String Reorderi... | 6 3
1 0 0 1 0 1
1 3 2
| 1
| 25,144 |
s103228780 | p00924 | u509278866 | 1528798951 | Python | Python3 | py | Accepted | 70 | 9040 | 1,767 | import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools
sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**10
mod = 998244353
dd = [(0,-1),(1,0),(0,1),(-1,0)]
ddn = [(0,-1),(1,-1),(1,0),(1,1),(0,1),(-1,-1),(-1,0),(-1,1)]
def LI(): return [int(x) for x in sys.stdi... | p00924 |
<script type="text/x-mathjax-config">
MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }});
</script>
<script type='text/javascript' src='http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML'></script>
</script>
<h2>Problem A:
Bit String Reorderi... | 6 3
1 0 0 1 0 1
1 3 2
| 1
| 25,145 |
s485873070 | p00924 | u591052358 | 1539869293 | Python | Python3 | py | Accepted | 30 | 6340 | 527 | import copy
N,M = [int(i) for i in input().split()]
b = [int(i) for i in input().split()]
p = [int(i) for i in input().split()]
def solve(num):
ret = 0
c = copy.deepcopy(b)
c_ = []
for i in range(M):
c_ += [(int(i%2 == num))] * p[i]
#print(c,c_)
for i in range(N):
if c[i] != c_[i]:
for j i... | p00924 |
<script type="text/x-mathjax-config">
MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }});
</script>
<script type='text/javascript' src='http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML'></script>
</script>
<h2>Problem A:
Bit String Reorderi... | 6 3
1 0 0 1 0 1
1 3 2
| 1
| 25,146 |
s573658134 | p00925 | u535943957 | 1417345482 | Python | Python3 | py | Accepted | 40 | 6724 | 293 | s = input()
t = int(input())
e1 = eval(s)
e2 = int(s[0])
i = 1
while i < len(s):
x = int(s[i+1])
if s[i] == '+':
e2 += x
else:
e2 *= x
i += 2
if e1 == t and e2 == t:
print("U")
elif e1 == t:
print("M")
elif e2 == t:
print("L")
else:
print("I") | p00925 |
<script type="text/x-mathjax-config">
MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }});
</script>
<script type='text/javascript' src='http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML'></script>
</script>
<h2>Problem B:
Miscalculation
</h2... | 1+2*3+4
11
| M
| 25,147 |
s447376677 | p00925 | u827448139 | 1420836621 | Python | Python3 | py | Accepted | 40 | 6728 | 162 | s,ans=input(),int(input())
x=int(s[0])
for i in range(1,len(s),2):
y=int(s[i+1])
x=x*y if s[i]=='*' else x+y
print("IMLU"[int(eval(s)==ans)+(int(x==ans)<<1)]) | p00925 |
<script type="text/x-mathjax-config">
MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }});
</script>
<script type='text/javascript' src='http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML'></script>
</script>
<h2>Problem B:
Miscalculation
</h2... | 1+2*3+4
11
| M
| 25,148 |
s055090930 | p00925 | u731235119 | 1422699416 | Python | Python | py | Accepted | 20 | 4268 | 639 | def lr_op(expr, length):
op = {"+": lambda x,y : x + y, "*": lambda x,y : x * y }
result = expr[0]
inc = 1
while inc < length:
result = op[expr[inc]](result,expr[inc+1])
inc += 2
return result
inputs = raw_input()
length = len(inputs)
expr = [int(inputs[i]) if i % 2 == 0 else inputs[i] for i in range(length)]
... | p00925 |
<script type="text/x-mathjax-config">
MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }});
</script>
<script type='text/javascript' src='http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML'></script>
</script>
<h2>Problem B:
Miscalculation
</h2... | 1+2*3+4
11
| M
| 25,149 |
s225135750 | p00925 | u633068244 | 1423510312 | Python | Python | py | Accepted | 20 | 4200 | 172 | s = raw_input()
a = int(raw_input())
m = eval(s)
l = eval("("*s.count("*")+s.replace("*",")*"))
print "U" if a == m == l else "M" if a == m != l else "L" if a == l else "I" | p00925 |
<script type="text/x-mathjax-config">
MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }});
</script>
<script type='text/javascript' src='http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML'></script>
</script>
<h2>Problem B:
Miscalculation
</h2... | 1+2*3+4
11
| M
| 25,150 |
s099431504 | p00925 | u633068244 | 1423510405 | Python | Python | py | Accepted | 20 | 4196 | 167 | s = raw_input()
a = int(raw_input())
m = eval(s)
l = eval("("*s.count("*")+s.replace("*",")*"))
print "U" if a == m == l else "M" if a == m else "L" if a == l else "I" | p00925 |
<script type="text/x-mathjax-config">
MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }});
</script>
<script type='text/javascript' src='http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML'></script>
</script>
<h2>Problem B:
Miscalculation
</h2... | 1+2*3+4
11
| M
| 25,151 |
s837588828 | p00925 | u633068244 | 1423510781 | Python | Python | py | Accepted | 20 | 4196 | 123 | s = raw_input()
a = int(raw_input())
print "IMLU"[int(eval(s) == a)+int(eval("("*s.count("*")+s.replace("*",")*")) == a)*2] | p00925 |
<script type="text/x-mathjax-config">
MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }});
</script>
<script type='text/javascript' src='http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML'></script>
</script>
<h2>Problem B:
Miscalculation
</h2... | 1+2*3+4
11
| M
| 25,152 |
s423778151 | p00925 | u009961299 | 1435713749 | Python | Python3 | py | Accepted | 40 | 6800 | 1,262 | # -*- coding: utf-8 -*-
def solvM(e):
p = [ 0 ]
def term():
res = 0
while p[ 0 ] < len ( e ) and "0" <= e[ p[ 0 ] ] <= "9":
res = res * 10 + ( ord ( e[ p[ 0 ] ] ) - ord ( "0" ) )
p[ 0 ] = p[ 0 ] + 1
return ( res )
def fact():
lv = term ( )
while p[ 0 ] < len ( e ):
if ( e[... | p00925 |
<script type="text/x-mathjax-config">
MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }});
</script>
<script type='text/javascript' src='http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML'></script>
</script>
<h2>Problem B:
Miscalculation
</h2... | 1+2*3+4
11
| M
| 25,153 |
s482241633 | p00925 | u078042885 | 1485106571 | Python | Python3 | py | Accepted | 30 | 7968 | 373 | import re
class c(int):
def __add__(self,n):
return c(int(self)+int(n))
def __mul__(self,n):
return c(int(self)*int(n))
s=input()
d=int(input())
a=eval(re.sub(r'(\d+)',r'c(\1)',s))
b=int(s[0])
for i in range(1,len(s),2):
if s[i]=='+':b+=int(s[i+1])
else:b*=int(s[i+1])
if(a==b==d):e='U'
... | p00925 |
<script type="text/x-mathjax-config">
MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }});
</script>
<script type='text/javascript' src='http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML'></script>
</script>
<h2>Problem B:
Miscalculation
</h2... | 1+2*3+4
11
| M
| 25,154 |
s964161766 | p00925 | u078042885 | 1485107230 | Python | Python3 | py | Accepted | 30 | 7708 | 193 | s,c=input(),int(input())
a=eval(s)
b=int(s[0])
for i in range(1,len(s),2):b=b+int(s[i+1]) if s[i]=='+' else b*int(s[i+1])
if(a==b==c):e='U'
elif(a==c):e='M'
elif(b==c):e='L'
else:e='I'
print(e) | p00925 |
<script type="text/x-mathjax-config">
MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }});
</script>
<script type='text/javascript' src='http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML'></script>
</script>
<h2>Problem B:
Miscalculation
</h2... | 1+2*3+4
11
| M
| 25,155 |
s073100029 | p00925 | u260980560 | 1512750806 | Python | Python3 | py | Accepted | 20 | 5608 | 1,038 | s = input()
l = len(s)
def parse1(s):
cur = 0
num = 0; res = 0; op = '+'
while cur < len(s):
if s[cur] in '+*':
if op is '+':
res += num
else:
res *= num
num = 0; op = s[cur]
else:
num = 10 * num + int(s[cur])
... | p00925 |
<script type="text/x-mathjax-config">
MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }});
</script>
<script type='text/javascript' src='http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML'></script>
</script>
<h2>Problem B:
Miscalculation
</h2... | 1+2*3+4
11
| M
| 25,156 |
s106522693 | p00925 | u506554532 | 1514347499 | Python | Python3 | py | Accepted | 20 | 5604 | 320 | def left2right(formula):
ans = int(formula[0])
for i in range(1,len(formula),2):
ans = eval(str(ans) + formula[i:i+2])
return ans
formula = input()
val = int(input())
if left2right(formula) == val:
print('U' if eval(formula) == val else 'L')
else:
print('M' if eval(formula) == val else 'I') | p00925 |
<script type="text/x-mathjax-config">
MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }});
</script>
<script type='text/javascript' src='http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML'></script>
</script>
<h2>Problem B:
Miscalculation
</h2... | 1+2*3+4
11
| M
| 25,157 |
s447621676 | p00925 | u211666125 | 1522588935 | Python | Python3 | py | Accepted | 20 | 5608 | 178 | s = '+'+input()
p = int(input())
n = 0
for a in [i+j for (i,j) in zip(s[::2], s[1::2])]:
n = eval(str(n)+a)
f = 1 if n==p else 0
f += 2 if eval(s)==p else 0
print('ILMU'[f])
| p00925 |
<script type="text/x-mathjax-config">
MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }});
</script>
<script type='text/javascript' src='http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML'></script>
</script>
<h2>Problem B:
Miscalculation
</h2... | 1+2*3+4
11
| M
| 25,158 |
s705283082 | p00925 | u509278866 | 1528258187 | Python | Python3 | py | Accepted | 70 | 9032 | 1,144 | import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools
sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**10
mod = 998244353
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF... | p00925 |
<script type="text/x-mathjax-config">
MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }});
</script>
<script type='text/javascript' src='http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML'></script>
</script>
<h2>Problem B:
Miscalculation
</h2... | 1+2*3+4
11
| M
| 25,159 |
s351315147 | p00925 | u855199458 | 1530603456 | Python | Python3 | py | Accepted | 20 | 5604 | 302 | # -*- coding: utf-8 -*-
S = input()
bob = int(input())
M = eval(S)
L = int(S[0])
for o, v in zip(S[1::2], S[2::2]):
if o == "*":
L *= int(v)
else:
L += int(v)
if M == L == bob:
print("U")
elif M == bob:
print("M")
elif L == bob:
print("L")
else:
print("I")
| p00925 |
<script type="text/x-mathjax-config">
MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }});
</script>
<script type='text/javascript' src='http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML'></script>
</script>
<h2>Problem B:
Miscalculation
</h2... | 1+2*3+4
11
| M
| 25,160 |
s073027745 | p00925 | u483930210 | 1580878908 | Python | Python3 | py | Accepted | 20 | 5604 | 397 | def f(s):
return eval(s)
def g(s):
ret = ord(s[0])-48
i = 1
while i < len(s):
if s[i] == '+':
ret += ord(s[i+1])-48
else:
ret *= ord(s[i+1])-48
i += 2
return ret
s = input()
n = int(input())
f1, f2 = (n == f(s)), (n == g(s))
if f1 and f2:
pri... | p00925 |
<script type="text/x-mathjax-config">
MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }});
</script>
<script type='text/javascript' src='http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML'></script>
</script>
<h2>Problem B:
Miscalculation
</h2... | 1+2*3+4
11
| M
| 25,161 |
s098728106 | p00925 | u464321546 | 1558000722 | Python | Python3 | py | Accepted | 40 | 8196 | 1,843 | #!usr/bin/env python3
from collections import defaultdict
from collections import deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
import itertools
sys.setrecursionlimit(10**5)
stdin = sys.stdin
bisect_left = bisect.bisect_left
bisect_right = bisect.bisect_right
def LI(): ret... | p00925 |
<script type="text/x-mathjax-config">
MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }});
</script>
<script type='text/javascript' src='http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML'></script>
</script>
<h2>Problem B:
Miscalculation
</h2... | 1+2*3+4
11
| M
| 25,162 |
s972101529 | p00925 | u853158149 | 1557999850 | Python | Python3 | py | Accepted | 50 | 8248 | 1,710 | #!usr/bin/env python3
from collections import defaultdict
from collections import deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
def LI(): return list(map(int, sys.stdin.readline().split()))
def I(): return int(sys.stdin.readline())
def LS():return list(map(list, sys.stdin.... | p00925 |
<script type="text/x-mathjax-config">
MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }});
</script>
<script type='text/javascript' src='http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML'></script>
</script>
<h2>Problem B:
Miscalculation
</h2... | 1+2*3+4
11
| M
| 25,163 |
s611200826 | p00925 | u281836941 | 1525240648 | Python | Python3 | py | Accepted | 30 | 6292 | 772 | # coding: utf-8
import functools
def M(s):
s=s.split('+')
for i in range(len(s)):
if '*' in s[i]:
s[i]=functools.reduce(lambda x,y:str(int(x)*int(y)),s[i].split('*'))
return int(functools.reduce(lambda x,y:str(int(x)+int(y)),s))
def L(s):
ret=0
i=0
ope=1
while i<len(s):... | p00925 |
<script type="text/x-mathjax-config">
MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }});
</script>
<script type='text/javascript' src='http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML'></script>
</script>
<h2>Problem B:
Miscalculation
</h2... | 1+2*3+4
11
| M
| 25,164 |
s856689248 | p00926 | u827448139 | 1420998188 | Python | Python3 | py | Accepted | 70 | 6724 | 296 | import sys
reader=(token for line in sys.stdin for token in line.split())
while 1:
try:
n=int(next(reader))
m=int(next(reader))
except: break
a=[1]*(n+1)
for i in range(m):
c=int(next(reader))-1
d=int(next(reader))-1
for i in range(c,d):
a[i]=3
print(sum(a)) | p00926 |
<script type="text/x-mathjax-config">
MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }});
</script>
<script type='text/javascript' src='http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML'></script>
</script>
<h2>Problem C:
Shopping
</h2>
<p>... | 10 3
3 7
8 9
2 5
| 23
| 25,165 |
s712060245 | p00926 | u633068244 | 1428306704 | Python | Python | py | Accepted | 30 | 4232 | 265 | N, m = map(int, raw_input().split())
three = [False]*N
for loop in xrange(m):
c, d = map(int, raw_input().split())
if c < d:
three[c:d] = [True]*len(three[c:d])
ans = 0
for i in xrange(N):
ans += 1
if three[i]:
ans += 2
print ans+1 | p00926 |
<script type="text/x-mathjax-config">
MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }});
</script>
<script type='text/javascript' src='http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML'></script>
</script>
<h2>Problem C:
Shopping
</h2>
<p>... | 10 3
3 7
8 9
2 5
| 23
| 25,166 |
s206867711 | p00926 | u260980560 | 1512742453 | Python | Python3 | py | Accepted | 30 | 5608 | 298 | N, m = map(int, input().split())
v = [0]*N
for i in range(m):
c, d = map(int, input().split())
v[c-1] += 1
v[d-1] -= 1
s = 0; fst = 0
ans = N+1
for i in range(N):
if s == 0 and v[i] > 0:
fst = i
s += v[i]
if s == 0 and v[i] < 0:
ans += (i - fst)*2
print(ans) | p00926 |
<script type="text/x-mathjax-config">
MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }});
</script>
<script type='text/javascript' src='http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML'></script>
</script>
<h2>Problem C:
Shopping
</h2>
<p>... | 10 3
3 7
8 9
2 5
| 23
| 25,167 |
s086467868 | p00926 | u509278866 | 1529983076 | Python | Python3 | py | Accepted | 70 | 9204 | 1,010 | import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools
sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**10
mod = 10**9+7
dd = [(0,-1),(1,0),(0,1),(-1,0)]
ddn = [(0,-1),(1,-1),(1,0),(1,1),(0,1),(-1,-1),(-1,0),(-1,1)]
def LI(): return [int(x) for x in sys.stdin.... | p00926 |
<script type="text/x-mathjax-config">
MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }});
</script>
<script type='text/javascript' src='http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML'></script>
</script>
<h2>Problem C:
Shopping
</h2>
<p>... | 10 3
3 7
8 9
2 5
| 23
| 25,168 |
s777342785 | p00926 | u464321546 | 1558006861 | Python | Python3 | py | Accepted | 40 | 8296 | 2,238 | #!usr/bin/env python3
from collections import defaultdict
from collections import deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
import itertools
sys.setrecursionlimit(10**5)
stdin = sys.stdin
bisect_left = bisect.bisect_left
bisect_right = bisect.bisect_right
def LI(): ret... | p00926 |
<script type="text/x-mathjax-config">
MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }});
</script>
<script type='text/javascript' src='http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML'></script>
</script>
<h2>Problem C:
Shopping
</h2>
<p>... | 10 3
3 7
8 9
2 5
| 23
| 25,169 |
s145150525 | p00926 | u853158149 | 1558001276 | Python | Python3 | py | Accepted | 50 | 8268 | 2,113 | #!usr/bin/env python3
from collections import defaultdict
from collections import deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
def LI(): return list(map(int, sys.stdin.readline().split()))
def I(): return int(sys.stdin.readline())
def LS():return list(map(list, sys.stdin.... | p00926 |
<script type="text/x-mathjax-config">
MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }});
</script>
<script type='text/javascript' src='http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML'></script>
</script>
<h2>Problem C:
Shopping
</h2>
<p>... | 10 3
3 7
8 9
2 5
| 23
| 25,170 |
s454004620 | p00926 | u316584871 | 1533919844 | Python | Python3 | py | Accepted | 90 | 5632 | 190 | N,m = map(int, input().split())
again = set()
for i in range(m):
a,b = map(int, input().split())
for k in range(a,b):
again.add(k)
r = N+1 + 2*(len(again))
print(r)
| p00926 |
<script type="text/x-mathjax-config">
MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }});
</script>
<script type='text/javascript' src='http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML'></script>
</script>
<h2>Problem C:
Shopping
</h2>
<p>... | 10 3
3 7
8 9
2 5
| 23
| 25,171 |
s250861057 | p00935 | u546285759 | 1491215152 | Python | Python3 | py | Accepted | 30 | 7824 | 811 | n = int(input())
length = int(n / 19) + 1
if n > 19 and n % 19 == 0:
length -= 1
d = []
for i in range(length):
d += list(map(int, input().split()))
start, end = 1, 10
l = []
flag = False
for j in range(1, len(d)+1):
for i in range(0, len(d)):
tmp = ''.join(map(str, d[i:i+j]))
if len(tmp) > ... | p00935 |
<script type="text/x-mathjax-config">
MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }});
</script>
<script type='text/javascript' src='http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML'></script>
</script>
<h2>Problem A
Decimal Sequences</h... | 3
3 0 1
| 2
| 25,174 |
s365872661 | p00935 | u728992264 | 1491833889 | Python | Python3 | py | Accepted | 30 | 7604 | 150 | n=int(input())
d=''.join([''.join(input().split())for i in range(n//19+(n%19!=0))])
i=0
while True:
if d.find(str(i))==-1:
print(i)
exit()
i+=1 | p00935 |
<script type="text/x-mathjax-config">
MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }});
</script>
<script type='text/javascript' src='http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML'></script>
</script>
<h2>Problem A
Decimal Sequences</h... | 3
3 0 1
| 2
| 25,175 |
s942407924 | p00935 | u728992264 | 1491834167 | Python | Python3 | py | Accepted | 20 | 7604 | 143 | n=int(input())
d=''.join(''.join(input().split())for i in[0]*(n//19+(n%19!=0)))
i=0
while 1:
if d.find(str(i))==-1:
print(i)
exit()
i+=1 | p00935 |
<script type="text/x-mathjax-config">
MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }});
</script>
<script type='text/javascript' src='http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML'></script>
</script>
<h2>Problem A
Decimal Sequences</h... | 3
3 0 1
| 2
| 25,176 |
s095562962 | p00935 | u728992264 | 1491834203 | Python | Python3 | py | Accepted | 20 | 7620 | 141 | j=''.join
n=int(input())
d=j(j(input().split())for i in[0]*(n//19+(n%19!=0)))
i=0
while 1:
if d.find(str(i))==-1:
print(i)
exit()
i+=1 | p00935 |
<script type="text/x-mathjax-config">
MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }});
</script>
<script type='text/javascript' src='http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML'></script>
</script>
<h2>Problem A
Decimal Sequences</h... | 3
3 0 1
| 2
| 25,177 |
s342975036 | p00935 | u728992264 | 1491834243 | Python | Python3 | py | Accepted | 30 | 7620 | 139 | j=''.join
n=int(input())
d=j(j(input().split())for i in[0]*(n//19+(n%19!=0)))
i=0
while 1:
if d.find(str(i))<0:
print(i)
exit()
i+=1 | p00935 |
<script type="text/x-mathjax-config">
MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }});
</script>
<script type='text/javascript' src='http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML'></script>
</script>
<h2>Problem A
Decimal Sequences</h... | 3
3 0 1
| 2
| 25,178 |
s552349706 | p00935 | u728992264 | 1491834394 | Python | Python3 | py | Accepted | 20 | 7624 | 139 | j=''.join
u=input
n=int(u())
d=j(j(u().split())for i in[0]*(n//19+(n%19!=0)))
i=0
while 1:
if d.find(str(i))<0:
print(i)
exit()
i+=1 | p00935 |
<script type="text/x-mathjax-config">
MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }});
</script>
<script type='text/javascript' src='http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML'></script>
</script>
<h2>Problem A
Decimal Sequences</h... | 3
3 0 1
| 2
| 25,179 |
s827568934 | p00935 | u728992264 | 1491834411 | Python | Python3 | py | Accepted | 20 | 7620 | 138 | j=''.join
u=input
n=int(u())
d=j(j(u().split())for i in[0]*(n//19+(n%19>0)))
i=0
while 1:
if d.find(str(i))<0:
print(i)
exit()
i+=1 | p00935 |
<script type="text/x-mathjax-config">
MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }});
</script>
<script type='text/javascript' src='http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML'></script>
</script>
<h2>Problem A
Decimal Sequences</h... | 3
3 0 1
| 2
| 25,180 |
s105791301 | p00935 | u506554532 | 1513501354 | Python | Python3 | py | Accepted | 20 | 5596 | 167 | N = int(input())
src = ''
while len(src) < N:
src += ''.join(input().split())
n = 0
while True:
if str(n) not in src:
print(n)
break
n += 1 | p00935 |
<script type="text/x-mathjax-config">
MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }});
</script>
<script type='text/javascript' src='http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML'></script>
</script>
<h2>Problem A
Decimal Sequences</h... | 3
3 0 1
| 2
| 25,181 |
s051449341 | p00935 | u023471147 | 1527160572 | Python | Python3 | py | Accepted | 20 | 5636 | 302 | n = int(input())
d = list()
while len(d) < n:
d.extend(list(map(int, input().split())))
appear = set()
for i in range(n):
for j in range(0, min(3, n - i)):
appear.add(int("".join(map(str, d[i:i + j + 1]))))
for i in range(1000):
if not i in appear:
print(i)
break
| p00935 |
<script type="text/x-mathjax-config">
MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }});
</script>
<script type='text/javascript' src='http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML'></script>
</script>
<h2>Problem A
Decimal Sequences</h... | 3
3 0 1
| 2
| 25,182 |
s407331322 | p00935 | u509278866 | 1528106424 | Python | Python3 | py | Accepted | 70 | 9088 | 1,153 | import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools
sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**10
mod = 998244353
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF... | p00935 |
<script type="text/x-mathjax-config">
MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }});
</script>
<script type='text/javascript' src='http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML'></script>
</script>
<h2>Problem A
Decimal Sequences</h... | 3
3 0 1
| 2
| 25,183 |
s739077400 | p00935 | u921810101 | 1544255728 | Python | Python3 | py | Accepted | 20 | 5620 | 184 | import sys
input()
a = []
for line in sys.stdin:
a.extend([x for x in line.split()])
a = "".join(a)
for i in range(int(a)):
if str(i) not in a:
print(i)
break
| p00935 |
<script type="text/x-mathjax-config">
MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }});
</script>
<script type='text/javascript' src='http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML'></script>
</script>
<h2>Problem A
Decimal Sequences</h... | 3
3 0 1
| 2
| 25,184 |
s784035676 | p00935 | u144532944 | 1543620158 | Python | Python3 | py | Accepted | 20 | 5604 | 160 | n = int(input())
d = []
while len(d) < n: d += input().split()
d = ''.join(d)
for i in range(1000000):
if str(i) not in d:
print(i)
break
| p00935 |
<script type="text/x-mathjax-config">
MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }});
</script>
<script type='text/javascript' src='http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML'></script>
</script>
<h2>Problem A
Decimal Sequences</h... | 3
3 0 1
| 2
| 25,185 |
s832225683 | p00957 | u099523067 | 1513474225 | Python | Python | py | Accepted | 10 | 4656 | 241 | l, k = map(int, raw_input().split())
d = [[0, 0] for i in xrange(l + 1)]
d[0][1] = 1
s = 0
for i in xrange(1, l + 1):
d[i][0] = d[i - 1][1]
d[i][1] = d[i - 1][0]
if i >= k:
d[i][0] += d[i - k][1]
s += d[i][0]
print s | p00957 |
<script type="text/x-mathjax-config">
MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], skipTags: ["script","noscript","style","textarea","code"], processEscapes: true }});
</script>
<script type="text/javascript" async src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.1/MathJax.js?config... | 5 3
| 6
| 25,186 |
s502580823 | p00957 | u506554532 | 1513485787 | Python | Python3 | py | Accepted | 20 | 5604 | 274 | l,k = map(int,input().split())
dp = [[0,0] for i in range(l+1)]
dp[1][0] = 1
if k <= l:
dp[k][0] = 1
for h in range(1,l):
dp[h+1][0] += dp[h][1]
dp[h+1][1] += dp[h][0]
if h+k <= l:
dp[h+k][1] += dp[h][0]
ans = 0
for b,w in dp:
ans += b
print(ans) | p00957 |
<script type="text/x-mathjax-config">
MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], skipTags: ["script","noscript","style","textarea","code"], processEscapes: true }});
</script>
<script type="text/javascript" async src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.1/MathJax.js?config... | 5 3
| 6
| 25,187 |
s876004601 | p00957 | u260980560 | 1514479709 | Python | Python3 | py | Accepted | 20 | 5616 | 311 | l, k = map(int, input().split())
memo = {(l, 0): 1, (l, 1): 0}
def dfs(cur, dark):
if (cur, dark) in memo:
return memo[cur, dark]
res = dfs(cur + 1, dark^1) + (dark^1)
if dark and cur + k <= l:
res += dfs(cur + k, dark^1)
memo[cur, dark] = res
return res
print(dfs(0, 1)) | p00957 |
<script type="text/x-mathjax-config">
MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], skipTags: ["script","noscript","style","textarea","code"], processEscapes: true }});
</script>
<script type="text/javascript" async src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.1/MathJax.js?config... | 5 3
| 6
| 25,188 |
s850251141 | p00957 | u724548524 | 1526349847 | Python | Python3 | py | Accepted | 20 | 5664 | 285 | import math
l, k = map(int, input().split())
c = 0
for i in range(1, int((l + 1) / 2) + 1):
for j in range(i + 1):
if 2 * i - 1 + j * (k - 1) <= l:
c += math.factorial(i) / math.factorial(j) / math.factorial(i - j)
else:
break
print(int(c))
| p00957 |
<script type="text/x-mathjax-config">
MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], skipTags: ["script","noscript","style","textarea","code"], processEscapes: true }});
</script>
<script type="text/javascript" async src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.1/MathJax.js?config... | 5 3
| 6
| 25,189 |
s215629066 | p00957 | u467175809 | 1575092078 | Python | Python | py | Accepted | 20 | 6168 | 404 | #!/usr/bin/env python
from collections import deque, defaultdict
import itertools as ite
import sys
import math
import decimal
sys.setrecursionlimit(1000000)
INF = 10 ** 18
MOD = 10 ** 9 + 7
l, k = map(int, raw_input().split())
DP1 = [0] * 200
DP2 = [1] + [0] * 200
for i in range(1, l + 1):
DP1[i] = DP2[i - 1]... | p00957 |
<script type="text/x-mathjax-config">
MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], skipTags: ["script","noscript","style","textarea","code"], processEscapes: true }});
</script>
<script type="text/javascript" async src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.1/MathJax.js?config... | 5 3
| 6
| 25,190 |
s595508191 | p00957 | u244636821 | 1573914706 | Python | Python3 | py | Accepted | 20 | 5620 | 814 | #!/usr/bin/python3
import os
import sys
def main():
L, K = read_ints()
print(solve(L, K))
def solve(L, K):
D = [[0, 0] for _ in range(L + 1)]
D[1][0] = 1
if K <= L:
D[K][0] = 1
for i in range(1, L):
D[i + 1][1] += D[i][0]
D[i + 1][0] += D[i][1]
if i + K <= L... | p00957 |
<script type="text/x-mathjax-config">
MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], skipTags: ["script","noscript","style","textarea","code"], processEscapes: true }});
</script>
<script type="text/javascript" async src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.1/MathJax.js?config... | 5 3
| 6
| 25,191 |
s973374039 | p00957 | u215870135 | 1570268442 | Python | Python3 | py | Accepted | 20 | 5608 | 380 | import sys
input = sys.stdin.readline
def main():
l, k = map(int, input().split())
dp = [[0] * 2 for i in range(101)]
dp[0][1] = 1
ans = 0
for i in range(1, l+1):
dp[i][0] = dp[i-1][1]
if i-k >= 0:
dp[i][0] += dp[i-k][1]
dp[i][1] = dp[i-1][0]
ans += dp[i... | p00957 |
<script type="text/x-mathjax-config">
MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], skipTags: ["script","noscript","style","textarea","code"], processEscapes: true }});
</script>
<script type="text/javascript" async src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.1/MathJax.js?config... | 5 3
| 6
| 25,192 |
s973477376 | p00957 | u226888928 | 1561715592 | Python | Python3 | py | Accepted | 30 | 6288 | 434 | from functools import lru_cache # おまじない
l,k=map(int,input().split())
@lru_cache() # python 素晴らしい
def rec(i,isBlack):
if i < 0: return 0
if i == 0: return 1 if not isBlack else 0 # black at bottom
if isBlack: # top is black
return rec(i-1, False) + rec(i-k, False)
else: # top is white
... | p00957 |
<script type="text/x-mathjax-config">
MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], skipTags: ["script","noscript","style","textarea","code"], processEscapes: true }});
</script>
<script type="text/javascript" async src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.1/MathJax.js?config... | 5 3
| 6
| 25,193 |
s071612949 | p00957 | u853158149 | 1560417874 | Python | Python3 | py | Accepted | 50 | 8236 | 1,446 | #!usr/bin/env python3
from collections import defaultdict
from collections import deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
def LI(): return list(map(int, sys.stdin.readline().split()))
def I(): return int(sys.stdin.readline())
def LS():return list(map(list, sys.stdin.... | p00957 |
<script type="text/x-mathjax-config">
MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], skipTags: ["script","noscript","style","textarea","code"], processEscapes: true }});
</script>
<script type="text/javascript" async src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.1/MathJax.js?config... | 5 3
| 6
| 25,194 |
s578522821 | p00957 | u509278866 | 1543212560 | Python | Python3 | py | Accepted | 60 | 9032 | 1,131 | import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools
sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**13
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) for x in sys.stdin.... | p00957 |
<script type="text/x-mathjax-config">
MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], skipTags: ["script","noscript","style","textarea","code"], processEscapes: true }});
</script>
<script type="text/javascript" async src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.1/MathJax.js?config... | 5 3
| 6
| 25,195 |
s254634030 | p00957 | u234579471 | 1543210779 | Python | Python3 | py | Accepted | 20 | 5600 | 277 | l, k = map(int, input().split())
dpW = [0] * 101
dpB = [0] * 101
dpW[0] = 1
ans = 0
for i in range(1, l + 1):
if i >= k:
dpB[i] += dpW[i - k]
ans += dpW[i - k]
dpB[i] += dpW[i - 1]
dpW[i] += dpB[i - 1]
ans += dpW[i - 1]
print(ans)
| p00957 |
<script type="text/x-mathjax-config">
MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], skipTags: ["script","noscript","style","textarea","code"], processEscapes: true }});
</script>
<script type="text/javascript" async src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.1/MathJax.js?config... | 5 3
| 6
| 25,196 |
s550096832 | p00957 | u591052358 | 1539752842 | Python | Python3 | py | Accepted | 20 | 5604 | 269 | l , k = [int(i) for i in input().split()]
INIT = 0
tableB = [INIT] * 110
tableW = [INIT] * 110
tableW[0] = 1
for i in range(1,l+1):
tableB[i] += tableW[i-1]
if i - k >= 0:
tableB[i] += tableW[i-k]
tableW[i+1] = tableB[i]
print(sum(tableB))
#print(tableB)
| p00957 |
<script type="text/x-mathjax-config">
MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], skipTags: ["script","noscript","style","textarea","code"], processEscapes: true }});
</script>
<script type="text/javascript" async src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.1/MathJax.js?config... | 5 3
| 6
| 25,197 |
s377231894 | p00963 | u260980560 | 1514609403 | Python | Python3 | py | Accepted | 20 | 5720 | 464 | from math import cos, sin, pi, sqrt
B = ["BC", "CD", "DB"]
XY0, d0, l0, XY1, d1, l1 = open(0).read().split()
d0, l0, d1, l1 = map(int, [d0, l0, d1, l1])
def calc(XY, d, l):
angle = B.index(XY) * 60 + d
x = l * cos(pi*angle/180)
y = l * sin(pi*angle/180)
x = x + y/sqrt(3)
y = y * 2/sqrt(3)
x = x... | p00963 |
<script type="text/x-mathjax-config">
MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], skipTags: ["script","noscript","style","textarea","code"], processEscapes: true }});
</script>
<script type="text/javascript" async src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.1/MathJax.js?config... | CD 30 1
DB 30 1
| YES
| 25,198 |
s115388101 | p00968 | u998437062 | 1573652201 | Python | Python3 | py | Accepted | 20 | 5988 | 624 | n = int(input())
ss = [input() for _ in range(n + 1)]
sp = [[s[0]] for s in ss]
for i, s in enumerate(ss):
for j in range(1, len(s)):
if s[j - 1].isdigit() != s[j].isdigit():
sp[i].append('')
sp[i][-1] += s[j]
s0 = sp[0]
for s in sp[1:]:
p = 0
m = min(len(s0), len(s))
while p... | p00968 | <h2>Digits Are Not Just Characters</h2>
<p>
Mr. Manuel Majorana Minore made a number of files with numbers in their names. He wants to have a list of the files, but the file listing command commonly used lists them in an order different from what he prefers, interpreting digit sequences in them as ASCII code sequenc... | 2
file10
file20
file3
| +
-
| 25,199 |
s351925159 | p00968 | u244636821 | 1573216629 | Python | Python3 | py | Accepted | 40 | 7060 | 1,555 | #!/usr/bin/python3
import array
from fractions import Fraction
import functools
import itertools
import math
import os
import sys
def main():
N = read_int()
A = inp()
for _ in range(N):
print('-' if solve(inp(), A) < 0 else '+')
def solve(A, B):
i = 0
j = 0
N = len(A)
M = len(B)... | p00968 | <h2>Digits Are Not Just Characters</h2>
<p>
Mr. Manuel Majorana Minore made a number of files with numbers in their names. He wants to have a list of the files, but the file listing command commonly used lists them in an order different from what he prefers, interpreting digit sequences in them as ASCII code sequenc... | 2
file10
file20
file3
| +
-
| 25,200 |
s010942033 | p00968 | u226888928 | 1561109741 | Python | Python3 | py | Accepted | 40 | 6672 | 236 | import re
n=int(input())
s=[ ''.join(map(lambda x : '{0:09d}'.format(int(x)) if '0' <= x[0] <= '9' else x, re.sub(r'\d+', r' \g<0> ',input()).split()))for _ in range(n+1) ]
for i in range(1,n+1):
print('-' if s[i] < s[0] else '+')
| p00968 | <h2>Digits Are Not Just Characters</h2>
<p>
Mr. Manuel Majorana Minore made a number of files with numbers in their names. He wants to have a list of the files, but the file listing command commonly used lists them in an order different from what he prefers, interpreting digit sequences in them as ASCII code sequenc... | 2
file10
file20
file3
| +
-
| 25,201 |
s386957348 | p00968 | u300645821 | 1544369547 | Python | Python | py | Accepted | 10 | 4704 | 672 | def solve(s,t):
idx=0
while idx<len(s):
if s[idx].isdigit(): break
idx+=1
if t[:idx]<s[:idx]:
return '-'
elif t[:idx]>s[:idx] or s==t:
return '+'
elif len(t)==idx:
return '-'
elif len(s)==idx or not t[idx].isdigit():
return '+'
else:
a=''
idx2=idx
while idx2<len(s) and s[idx2].isdigit():
a+=... | p00968 | <h2>Digits Are Not Just Characters</h2>
<p>
Mr. Manuel Majorana Minore made a number of files with numbers in their names. He wants to have a list of the files, but the file listing command commonly used lists them in an order different from what he prefers, interpreting digit sequences in them as ASCII code sequenc... | 2
file10
file20
file3
| +
-
| 25,202 |
s259628029 | p00968 | u281836941 | 1544330927 | Python | Python3 | py | Accepted | 20 | 5612 | 486 | # coding: utf-8
# Your code here!
def ssplit(s):
tp=0
tmp=""
ret=[]
for c in s:
if c.isdigit():
tmp+=c
else:
if tmp!="":
ret.append((0,int(tmp)))
tmp=""
ret.append((1,ord(c)))
if tmp!="":
ret.append((0,int(tm... | p00968 | <h2>Digits Are Not Just Characters</h2>
<p>
Mr. Manuel Majorana Minore made a number of files with numbers in their names. He wants to have a list of the files, but the file listing command commonly used lists them in an order different from what he prefers, interpreting digit sequences in them as ASCII code sequenc... | 2
file10
file20
file3
| +
-
| 25,203 |
s199603394 | p00968 | u670914305 | 1544322855 | Python | Python3 | py | Accepted | 30 | 5828 | 870 | N = int(input())
S = [input() for _ in range(N + 1)]
def convert(s):
l = []
for i in range(len(s)):
if s[i].isdigit():
if len(l) != 0 and isinstance(l[-1], list):
l[-1].append(s[i])
else:
l.append([s[i]])
else:
l.append(s[i])
... | p00968 | <h2>Digits Are Not Just Characters</h2>
<p>
Mr. Manuel Majorana Minore made a number of files with numbers in their names. He wants to have a list of the files, but the file listing command commonly used lists them in an order different from what he prefers, interpreting digit sequences in them as ASCII code sequenc... | 2
file10
file20
file3
| +
-
| 25,204 |
s165630019 | p00968 | u314932236 | 1544320611 | Python | Python3 | py | Accepted | 20 | 5628 | 876 | import sys
sys.setrecursionlimit(10**6)
def tl(s):
pre = False
ref = []
for i in s:
if ord(i) < 58:
if pre:
ref[-1] = [True, ref[-1][1]*10 + int(i)]
else:
pre = True
ref += [[True, int(i)]]
else:
ref += [[False, i]]
pre=False
return ref
def main():
n = int(input())
pibot = tl(input()... | p00968 | <h2>Digits Are Not Just Characters</h2>
<p>
Mr. Manuel Majorana Minore made a number of files with numbers in their names. He wants to have a list of the files, but the file listing command commonly used lists them in an order different from what he prefers, interpreting digit sequences in them as ASCII code sequenc... | 2
file10
file20
file3
| +
-
| 25,205 |
s327284029 | p00979 | u011621222 | 1586868843 | Python | Python3 | py | Accepted | 20 | 5656 | 423 | from sys import stdin, stdout
import math
n = int(stdin.readline().strip())
reserved = 1
maxspeed = 1
while True:
if reserved + maxspeed * 3 > n:
break
maxspeed *= 3
reserved += maxspeed * 2
ans = 1
n -= 1
i = 3
while i < maxspeed:
ans += 2
n -= i * 2
i *= 3
n -= maxspeed
i = maxsp... | p00979 | <h2>Fast Forwarding</h2>
<p>
Mr. Anderson frequently rents video tapes of his favorite classic films. Watching the films so many times, he has learned the precise start times of his favorite scenes in all such films. He now wants to find how to wind the tape to watch his favorite scene as quickly as possible on his ... | 19
| 5
| 25,206 |
s148509719 | p00979 | u467175809 | 1575699446 | Python | Python | py | Accepted | 20 | 6176 | 461 | #!/usr/bin/env python
from collections import deque, defaultdict
import itertools as ite
import sys
import math
import decimal
sys.setrecursionlimit(1000000)
INF = 10 ** 18
MOD = 10 ** 9 + 7
t = input()
ans = t
for p in range(1, 50):
S = 2 * sum(3 ** i for i in range(p)) - 1
if S > t:
break
num... | p00979 | <h2>Fast Forwarding</h2>
<p>
Mr. Anderson frequently rents video tapes of his favorite classic films. Watching the films so many times, he has learned the precise start times of his favorite scenes in all such films. He now wants to find how to wind the tape to watch his favorite scene as quickly as possible on his ... | 19
| 5
| 25,207 |
s757270569 | p00979 | u509278866 | 1574498041 | Python | Python3 | py | Accepted | 60 | 9040 | 1,069 | import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,copy,functools
import time,random
sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**10
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 list(map(int, sys.st... | p00979 | <h2>Fast Forwarding</h2>
<p>
Mr. Anderson frequently rents video tapes of his favorite classic films. Watching the films so many times, he has learned the precise start times of his favorite scenes in all such films. He now wants to find how to wind the tape to watch his favorite scene as quickly as possible on his ... | 19
| 5
| 25,208 |
s753984087 | p00979 | u009961299 | 1573966886 | Python | Python3 | py | Accepted | 20 | 5596 | 268 | #!/usr/bin/env python3
t = int(input())
count = 0
speed = 1
margin = 0
while t > 0:
t -= speed
count += 1
if margin + speed * 3 <= t:
speed *= 3
margin += speed
elif t < margin:
margin -= speed
speed /= 3
print(count)
| p00979 | <h2>Fast Forwarding</h2>
<p>
Mr. Anderson frequently rents video tapes of his favorite classic films. Watching the films so many times, he has learned the precise start times of his favorite scenes in all such films. He now wants to find how to wind the tape to watch his favorite scene as quickly as possible on his ... | 19
| 5
| 25,209 |
s250213603 | p00979 | u244636821 | 1573955239 | Python | Python3 | py | Accepted | 20 | 5612 | 833 | #!/usr/bin/python3
import os
import sys
def main():
T = read_int()
print(solve(T))
def solve(T):
if T <= 3:
return T
sec = 1
T -= 1
f = 3
while T >= 2 * f:
T -= 2 * f
f *= 3
sec += 2
if T >= f:
T -= f
sec += 1
else:
f //=... | p00979 | <h2>Fast Forwarding</h2>
<p>
Mr. Anderson frequently rents video tapes of his favorite classic films. Watching the films so many times, he has learned the precise start times of his favorite scenes in all such films. He now wants to find how to wind the tape to watch his favorite scene as quickly as possible on his ... | 19
| 5
| 25,210 |
s309678562 | p00980 | u668489394 | 1580090788 | Python | Python3 | py | Accepted | 60 | 5728 | 1,743 | def isValid(row, col, ROWS, COLS):
return row >= 0 and row < ROWS and col >= 0 and col < COLS
def isSteep(board, row, col, ROWS, COLS):
global adjR, adjC
h = board[row][col]
for i in range(4):
rr = row + adjR[i]
cc = col + adjC[i]
if isValid(rr, cc, ROWS, COLS):
dif... | p00980 | <h2>Estimating the Flood Risk</h2>
<p>
Mr. Boat is the owner of a vast extent of land. As many typhoons have struck Japan this year, he became concerned of flood risk of his estate and he wants to know the average altitude of his land. The land is too vast to measure the altitude at many spots. As no steep slopes ar... | 5 4 2
1 1 10
5 4 3
| 130
| 25,211 |
s814459036 | p00980 | u509278866 | 1574498940 | Python | Python3 | py | Accepted | 70 | 9344 | 1,795 | import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,copy,functools
import time,random
sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**10
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 list(map(int, sys.st... | p00980 | <h2>Estimating the Flood Risk</h2>
<p>
Mr. Boat is the owner of a vast extent of land. As many typhoons have struck Japan this year, he became concerned of flood risk of his estate and he wants to know the average altitude of his land. The land is too vast to measure the altitude at many spots. As no steep slopes ar... | 5 4 2
1 1 10
5 4 3
| 130
| 25,212 |
s992201324 | p00980 | u244636821 | 1573956944 | Python | Python3 | py | Accepted | 30 | 6012 | 1,454 | #!/usr/bin/python3
import os
import sys
def main():
W, D, N = read_ints()
M = [tuple(read_ints()) for _ in range(N)]
ans = solve(W, D, N, M)
if ans is None:
print('No')
else:
print(ans)
def solve(W, D, N, M):
INF = 999
H = [[INF] * W for _ in range(D)]
hmap = {}
... | p00980 | <h2>Estimating the Flood Risk</h2>
<p>
Mr. Boat is the owner of a vast extent of land. As many typhoons have struck Japan this year, he became concerned of flood risk of his estate and he wants to know the average altitude of his land. The land is too vast to measure the altitude at many spots. As no steep slopes ar... | 5 4 2
1 1 10
5 4 3
| 130
| 25,213 |
s979339198 | p00991 | u847467233 | 1531490951 | Python | Python3 | py | Accepted | 20 | 5668 | 382 | # AOJ 1501: Grid
# Python3 2018.7.13 bal4u
from math import factorial
def comb (n, k):
return factorial(n)//factorial(n-k)//factorial(k)
k = 0
r, c, a1, a2, b1, b2 = map(int, input().split())
dr = abs(a1-b1)
if dr > r-dr: dr = r-dr
if (dr << 1) == r: k += 1
dc = abs(a2-b2)
if dc > c-dc: dc = c-dc
if (dc << 1) == ... | p00991 |
<h1>Problem B : Grid</h1>
<p>
<i>r</i> × <i>c</i> の2次元グリッド上の2つの座標 (<i>a<sub>1</sub></i>,<i>a<sub>2</sub></i>) と (<i>b<sub>1</sub></i>,<i>b<sub>2</sub></i>) が与えられる。
あるマス (e,f) から (e+1,f)、(e-1,f)、(e,f+1)、(e,f-1) のどれかのマスに移動するコストを1とする。
また、(e,c-1) と (e,0)、(r-1,f) と (0,f) の間もコスト1で移動することができる。
この時に1つ目の座標から2つ目の座標へ最短コストで移動できる... | 4 4 0 0 3 3
| 2
| 25,214 |
s779447546 | p00991 | u696166817 | 1410951040 | Python | Python3 | py | Accepted | 40 | 6796 | 1,512 | # Edit: 2014/09/09
# Lang: Python3
# Time: .00s
from math import factorial
if __name__ == "__main__":
# a, b, c, d, e, f = map(int, input().strip("\n").split(" "))
r, c, ar, ac, br, bc = map(int, input().strip("\n").split(" "))
maxans = 100000007 # 100,000,007
# maxn = 100000007
# tate Row
... | p00991 |
<h1>Problem B : Grid</h1>
<p>
<i>r</i> × <i>c</i> の2次元グリッド上の2つの座標 (<i>a<sub>1</sub></i>,<i>a<sub>2</sub></i>) と (<i>b<sub>1</sub></i>,<i>b<sub>2</sub></i>) が与えられる。
あるマス (e,f) から (e+1,f)、(e-1,f)、(e,f+1)、(e,f-1) のどれかのマスに移動するコストを1とする。
また、(e,c-1) と (e,0)、(r-1,f) と (0,f) の間もコスト1で移動することができる。
この時に1つ目の座標から2つ目の座標へ最短コストで移動できる... | 4 4 0 0 3 3
| 2
| 25,215 |
s408559399 | p00991 | u696166817 | 1410951196 | Python | Python3 | py | Accepted | 40 | 6792 | 1,425 | # Edit: 2014/09/09
# Lang: Python3
# Time: .00s
from math import factorial
if __name__ == "__main__":
r, c, ar, ac, br, bc = map(int, input().strip("\n").split(" "))
maxans = 100000007 # 100,000,007
# tate Row
dr = min(abs(br - ar), r - abs(br - ar))
if 2 * dr == r:
gainr = 2
else:
... | p00991 |
<h1>Problem B : Grid</h1>
<p>
<i>r</i> × <i>c</i> の2次元グリッド上の2つの座標 (<i>a<sub>1</sub></i>,<i>a<sub>2</sub></i>) と (<i>b<sub>1</sub></i>,<i>b<sub>2</sub></i>) が与えられる。
あるマス (e,f) から (e+1,f)、(e-1,f)、(e,f+1)、(e,f-1) のどれかのマスに移動するコストを1とする。
また、(e,c-1) と (e,0)、(r-1,f) と (0,f) の間もコスト1で移動することができる。
この時に1つ目の座標から2つ目の座標へ最短コストで移動できる... | 4 4 0 0 3 3
| 2
| 25,216 |
s488805858 | p00991 | u696166817 | 1410951299 | Python | Python3 | py | Accepted | 40 | 6796 | 573 | # Edit: 2014/09/17
# Lang: Python3
# Time: 00.04s
from math import factorial
if __name__ == "__main__":
r, c, ar, ac, br, bc = map(int, input().strip("\n").split(" "))
maxans = 100000007 # 100,000,007
# tate Row
dr = min(abs(br - ar), r - abs(br - ar))
if 2 * dr == r:
gainr = 2
else:... | p00991 |
<h1>Problem B : Grid</h1>
<p>
<i>r</i> × <i>c</i> の2次元グリッド上の2つの座標 (<i>a<sub>1</sub></i>,<i>a<sub>2</sub></i>) と (<i>b<sub>1</sub></i>,<i>b<sub>2</sub></i>) が与えられる。
あるマス (e,f) から (e+1,f)、(e-1,f)、(e,f+1)、(e,f-1) のどれかのマスに移動するコストを1とする。
また、(e,c-1) と (e,0)、(r-1,f) と (0,f) の間もコスト1で移動することができる。
この時に1つ目の座標から2つ目の座標へ最短コストで移動できる... | 4 4 0 0 3 3
| 2
| 25,217 |
s018375266 | p00991 | u186082958 | 1480443608 | Python | Python3 | py | Accepted | 60 | 8164 | 347 | def func (x):
if x:
return int(x)*func(x-1)
else:
return (1)
def comb (x,y):
return func(x)//func(x-y)//func(y)
import sys
sys.setrecursionlimit(10000)
w,h,ax,ay,bx,by=map(int,input().split())
dx=min(w-abs(ax-bx),abs(ax-bx))
dy=min(h-abs(ay-by),abs(ay-by))
ans=1
if dx*2==w:ans*=2
if dy*2==h:ans*=2
ans*=comb(dx+... | p00991 |
<h1>Problem B : Grid</h1>
<p>
<i>r</i> × <i>c</i> の2次元グリッド上の2つの座標 (<i>a<sub>1</sub></i>,<i>a<sub>2</sub></i>) と (<i>b<sub>1</sub></i>,<i>b<sub>2</sub></i>) が与えられる。
あるマス (e,f) から (e+1,f)、(e-1,f)、(e,f+1)、(e,f-1) のどれかのマスに移動するコストを1とする。
また、(e,c-1) と (e,0)、(r-1,f) と (0,f) の間もコスト1で移動することができる。
この時に1つ目の座標から2つ目の座標へ最短コストで移動できる... | 4 4 0 0 3 3
| 2
| 25,218 |
s361856510 | p00991 | u186082958 | 1480443714 | Python | Python3 | py | Accepted | 30 | 7800 | 322 | import sys
from math import factorial
sys.setrecursionlimit(10000)
def comb (x,y):
return factorial(x)//factorial(x-y)//factorial(y)
w,h,ax,ay,bx,by=map(int,input().split())
dx=min(w-abs(ax-bx),abs(ax-bx))
dy=min(h-abs(ay-by),abs(ay-by))
ans=1
if dx*2==w:ans*=2
if dy*2==h:ans*=2
ans*=comb(dx+dy,dx)
print(ans%10000000... | p00991 |
<h1>Problem B : Grid</h1>
<p>
<i>r</i> × <i>c</i> の2次元グリッド上の2つの座標 (<i>a<sub>1</sub></i>,<i>a<sub>2</sub></i>) と (<i>b<sub>1</sub></i>,<i>b<sub>2</sub></i>) が与えられる。
あるマス (e,f) から (e+1,f)、(e-1,f)、(e,f+1)、(e,f-1) のどれかのマスに移動するコストを1とする。
また、(e,c-1) と (e,0)、(r-1,f) と (0,f) の間もコスト1で移動することができる。
この時に1つ目の座標から2つ目の座標へ最短コストで移動できる... | 4 4 0 0 3 3
| 2
| 25,219 |
s402658230 | p00991 | u186082958 | 1480443872 | Python | Python3 | py | Accepted | 30 | 7792 | 282 | from math import factorial
def comb (x,y):
return factorial(x)//factorial(x-y)//factorial(y)
w,h,ax,ay,bx,by=map(int,input().split())
dx=min(w-abs(ax-bx),abs(ax-bx))
dy=min(h-abs(ay-by),abs(ay-by))
ans=1
if dx*2==w:ans*=2
if dy*2==h:ans*=2
ans*=comb(dx+dy,dx)
print(ans%100000007) | p00991 |
<h1>Problem B : Grid</h1>
<p>
<i>r</i> × <i>c</i> の2次元グリッド上の2つの座標 (<i>a<sub>1</sub></i>,<i>a<sub>2</sub></i>) と (<i>b<sub>1</sub></i>,<i>b<sub>2</sub></i>) が与えられる。
あるマス (e,f) から (e+1,f)、(e-1,f)、(e,f+1)、(e,f-1) のどれかのマスに移動するコストを1とする。
また、(e,c-1) と (e,0)、(r-1,f) と (0,f) の間もコスト1で移動することができる。
この時に1つ目の座標から2つ目の座標へ最短コストで移動できる... | 4 4 0 0 3 3
| 2
| 25,220 |
s467622357 | p00991 | u186082958 | 1480443971 | Python | Python3 | py | Accepted | 50 | 7780 | 278 | from math import factorial
def comb (x,y):
return factorial(x)//factorial(x-y)//factorial(y)
w,h,ax,ay,bx,by=map(int,input().split())
dx=abs(ax-bx)
dx=min(dx,w-dx)
dy=abs(ay-by)
dy=min(dy,h-dy)
ans=1
if dx*2==w:ans*=2
if dy*2==h:ans*=2
ans*=comb(dx+dy,dx)
print(ans%100000007) | p00991 |
<h1>Problem B : Grid</h1>
<p>
<i>r</i> × <i>c</i> の2次元グリッド上の2つの座標 (<i>a<sub>1</sub></i>,<i>a<sub>2</sub></i>) と (<i>b<sub>1</sub></i>,<i>b<sub>2</sub></i>) が与えられる。
あるマス (e,f) から (e+1,f)、(e-1,f)、(e,f+1)、(e,f-1) のどれかのマスに移動するコストを1とする。
また、(e,c-1) と (e,0)、(r-1,f) と (0,f) の間もコスト1で移動することができる。
この時に1つ目の座標から2つ目の座標へ最短コストで移動できる... | 4 4 0 0 3 3
| 2
| 25,221 |
s731270079 | p00991 | u186082958 | 1480444521 | Python | Python3 | py | Accepted | 30 | 7804 | 274 | from math import factorial
def comb (x,y):
return factorial(x)//factorial(x-y)//factorial(y)
w,h,ax,ay,bx,by=map(int,input().split())
dx=abs(ax-bx)
dx=min(dx,w-dx)
dy=abs(ay-by)
dy=min(dy,h-dy)
an=1
if dx*2==w:an*=2
if dy*2==h:an*=2
an*=comb(dx+dy,dx)
print(an%int(1E8+7)) | p00991 |
<h1>Problem B : Grid</h1>
<p>
<i>r</i> × <i>c</i> の2次元グリッド上の2つの座標 (<i>a<sub>1</sub></i>,<i>a<sub>2</sub></i>) と (<i>b<sub>1</sub></i>,<i>b<sub>2</sub></i>) が与えられる。
あるマス (e,f) から (e+1,f)、(e-1,f)、(e,f+1)、(e,f-1) のどれかのマスに移動するコストを1とする。
また、(e,c-1) と (e,0)、(r-1,f) と (0,f) の間もコスト1で移動することができる。
この時に1つ目の座標から2つ目の座標へ最短コストで移動できる... | 4 4 0 0 3 3
| 2
| 25,222 |
s021661809 | p00991 | u448439399 | 1585628280 | Python | Python3 | py | Accepted | 20 | 5792 | 536 | mod = 10**8+7
n = 1001
def comb(x, y):
if 2*y > x: return comb(x, x-y)
return fac[x] * inv[y]* inv[x-y] % mod
fac = [1]*(n+1)
inv = [1]*(n+1)
for i in range(2, n+1):
fac[i] = fac[i-1] * i % mod
inv[n] = pow(fac[n], mod-2, mod)
for i in range(n-1, 1, -1):
inv[i] = inv[i+1] * (i+1) % mod
r, c, a1, a2, ... | p00991 |
<h1>Problem B : Grid</h1>
<p>
<i>r</i> × <i>c</i> の2次元グリッド上の2つの座標 (<i>a<sub>1</sub></i>,<i>a<sub>2</sub></i>) と (<i>b<sub>1</sub></i>,<i>b<sub>2</sub></i>) が与えられる。
あるマス (e,f) から (e+1,f)、(e-1,f)、(e,f+1)、(e,f-1) のどれかのマスに移動するコストを1とする。
また、(e,c-1) と (e,0)、(r-1,f) と (0,f) の間もコスト1で移動することができる。
この時に1つ目の座標から2つ目の座標へ最短コストで移動できる... | 4 4 0 0 3 3
| 2
| 25,223 |
s400023770 | p00992 | u847467233 | 1531453659 | Python | Python3 | py | Accepted | 20 | 5604 | 237 | # AOJ 1502: War
# Python3 2018.7.13 bal4u
n = int(input())
ans = 1
h = [0]*126
for i in range(n):
v = int(input())
if v <= 125: h[v] += 1
ans += v
s = 0
for i in range(1, 126):
s += h[i-1]
if n > s+4*i: ans -= n-(s+4*i)
print(ans)
| p00992 |
<h1>Problem C : War</h1>
<p>
A国とB国という2つの国が戦争をしている。A国の軍人であるあなたは<i>n</i>人の兵士を率いて、B国の領土を占領する事になった。
</p>
<p>
B国の領土は2次元グリッドで表されている。あなたが最初に占領する場所は二次元グリッド上のある1マスである。
あなたが率いている兵士たちは、それぞれh_iの体力を持っている。
それぞれの兵士は体力を1を消費して移動することができる。
現在いるマスを(a,b)とすると、(a+1,b),(a-1,b),(a,b+1),(a,b-1)の4方向を移動先として選ぶことが可能である。
兵士は体力が0になったらそこから動くことができ... | 2
5
5
| 11
| 25,224 |
s430723703 | p00992 | u696166817 | 1410874824 | Python | Python3 | py | Accepted | 40 | 6728 | 630 | # Edit: 2014/09/14
# Lang: Python3
# Time: .00s
if __name__ == "__main__":
n = int(input())
# print("n:",n)
hl = []
for i in range(n):
hl.append(int(input()))
# print(hl)
# hl = [5, 5]
# hl = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10]
# hl = [1,2,3,4,5]
# hl = [1, 1, 1, 1, ... | p00992 |
<h1>Problem C : War</h1>
<p>
A国とB国という2つの国が戦争をしている。A国の軍人であるあなたは<i>n</i>人の兵士を率いて、B国の領土を占領する事になった。
</p>
<p>
B国の領土は2次元グリッドで表されている。あなたが最初に占領する場所は二次元グリッド上のある1マスである。
あなたが率いている兵士たちは、それぞれh_iの体力を持っている。
それぞれの兵士は体力を1を消費して移動することができる。
現在いるマスを(a,b)とすると、(a+1,b),(a-1,b),(a,b+1),(a,b-1)の4方向を移動先として選ぶことが可能である。
兵士は体力が0になったらそこから動くことができ... | 2
5
5
| 11
| 25,225 |
s040791242 | p00992 | u078042885 | 1487038802 | Python | Python3 | py | Accepted | 30 | 7648 | 156 | a=sorted([int(input()) for _ in [0]*int(input())])
c=b=0
for i in range(len(a)-1,-1,-1):
if a[i]<c//4:continue
else:b+=a[i]-c//4
c+=1
print(b+1) | p00992 |
<h1>Problem C : War</h1>
<p>
A国とB国という2つの国が戦争をしている。A国の軍人であるあなたは<i>n</i>人の兵士を率いて、B国の領土を占領する事になった。
</p>
<p>
B国の領土は2次元グリッドで表されている。あなたが最初に占領する場所は二次元グリッド上のある1マスである。
あなたが率いている兵士たちは、それぞれh_iの体力を持っている。
それぞれの兵士は体力を1を消費して移動することができる。
現在いるマスを(a,b)とすると、(a+1,b),(a-1,b),(a,b+1),(a,b-1)の4方向を移動先として選ぶことが可能である。
兵士は体力が0になったらそこから動くことができ... | 2
5
5
| 11
| 25,226 |
s915465988 | p00992 | u078042885 | 1487038920 | Python | Python3 | py | Accepted | 20 | 7652 | 139 | a=sorted([int(input()) for _ in [0]*int(input())])
c=b=0
for i in range(len(a)-1,-1,-1):
if a[i]>=c//4:b+=a[i]-c//4
c+=1
print(b+1) | p00992 |
<h1>Problem C : War</h1>
<p>
A国とB国という2つの国が戦争をしている。A国の軍人であるあなたは<i>n</i>人の兵士を率いて、B国の領土を占領する事になった。
</p>
<p>
B国の領土は2次元グリッドで表されている。あなたが最初に占領する場所は二次元グリッド上のある1マスである。
あなたが率いている兵士たちは、それぞれh_iの体力を持っている。
それぞれの兵士は体力を1を消費して移動することができる。
現在いるマスを(a,b)とすると、(a+1,b),(a-1,b),(a,b+1),(a,b-1)の4方向を移動先として選ぶことが可能である。
兵士は体力が0になったらそこから動くことができ... | 2
5
5
| 11
| 25,227 |
s028692841 | p00992 | u352394527 | 1547532090 | Python | Python3 | py | Accepted | 20 | 5608 | 373 | n = int(input())
h_lst = sorted([int(input()) for _ in range(n)])
def solve():
ans = 1
cnt = 0
while h_lst:
for _ in range(4):
if h_lst:
add = h_lst.pop() - cnt
if add <= 0:return ans
ans += add
else:
return an... | p00992 |
<h1>Problem C : War</h1>
<p>
A国とB国という2つの国が戦争をしている。A国の軍人であるあなたは<i>n</i>人の兵士を率いて、B国の領土を占領する事になった。
</p>
<p>
B国の領土は2次元グリッドで表されている。あなたが最初に占領する場所は二次元グリッド上のある1マスである。
あなたが率いている兵士たちは、それぞれh_iの体力を持っている。
それぞれの兵士は体力を1を消費して移動することができる。
現在いるマスを(a,b)とすると、(a+1,b),(a-1,b),(a,b+1),(a,b-1)の4方向を移動先として選ぶことが可能である。
兵士は体力が0になったらそこから動くことができ... | 2
5
5
| 11
| 25,228 |
s590878073 | p00993 | u847467233 | 1531454623 | Python | Python3 | py | Accepted | 20 | 5732 | 208 | # AOJ 1503: Numbers
# Python3 2018.7.13 bal4u
import sys
n = int(input())
if n == 1: print(4, 2, sep='\n'); sys.exit(0)
ans = 1
for i in range(2, n+2): ans *= i
print(ans+2)
for i in range(2, n+2): print(i)
| p00993 |
<H1>Problem D : Numbers </H1>
<p>
<i>n</i> が与えられるので、<i>n</i> 個の連続した正の整数を求めよ。
ただしすべての数が、1とその数自身以外の約数をもたなくてはならない。
</p>
<H2>Input</H2>
<p>
入力は以下のフォーマットで与えられる。
</p>
<pre>
<i>n</i>
</pre>
<p>
入力は以下の制約を満たす。<br>
1 ≤ <i>n</i> ≤ 1,500
</p>
<h2>Output</h2>
<p>
最初の行に、あなたが選んだ連続した<i>n</i> 個の正の整数の中で一番小さいものを出力せよ。<br>
2行目... | 2
| 8
2
3
| 25,229 |
s787804258 | p00993 | u858885710 | 1404315456 | Python | Python | py | Accepted | 20 | 4336 | 114 | print reduce( lambda x, y: x*y, [ x for x in range(1, 1501) ] )+2
for i in range(1, int(raw_input())+1): print i+1 | p00993 |
<H1>Problem D : Numbers </H1>
<p>
<i>n</i> が与えられるので、<i>n</i> 個の連続した正の整数を求めよ。
ただしすべての数が、1とその数自身以外の約数をもたなくてはならない。
</p>
<H2>Input</H2>
<p>
入力は以下のフォーマットで与えられる。
</p>
<pre>
<i>n</i>
</pre>
<p>
入力は以下の制約を満たす。<br>
1 ≤ <i>n</i> ≤ 1,500
</p>
<h2>Output</h2>
<p>
最初の行に、あなたが選んだ連続した<i>n</i> 個の正の整数の中で一番小さいものを出力せよ。<br>
2行目... | 2
| 8
2
3
| 25,230 |
s021750176 | p00993 | u696166817 | 1413197765 | Python | Python3 | py | Accepted | 40 | 6724 | 4,404 | # Edit: 2014/10/13
# Lang: Python3
# Time: 00.xxs
# File: pc1503.py
from functools import reduce
if __name__ == "__main__":
n = int(input()) # 1<=n<=1,500
#n1500 = reduce(lambda x,y: x*y, range(2,1501))+2
n1500 = 48119977967797748601669900935813797818348080406726138081308559411630575189001095591292230585... | p00993 |
<H1>Problem D : Numbers </H1>
<p>
<i>n</i> が与えられるので、<i>n</i> 個の連続した正の整数を求めよ。
ただしすべての数が、1とその数自身以外の約数をもたなくてはならない。
</p>
<H2>Input</H2>
<p>
入力は以下のフォーマットで与えられる。
</p>
<pre>
<i>n</i>
</pre>
<p>
入力は以下の制約を満たす。<br>
1 ≤ <i>n</i> ≤ 1,500
</p>
<h2>Output</h2>
<p>
最初の行に、あなたが選んだ連続した<i>n</i> 個の正の整数の中で一番小さいものを出力せよ。<br>
2行目... | 2
| 8
2
3
| 25,231 |
s186014252 | p00993 | u186082958 | 1483739359 | Python | Python3 | py | Accepted | 30 | 7808 | 232 | n=int(input())
if n==1:
print(4)
print(2)
elif n==2:
print(14)
print(2)
print(3)
else:
ans=1
for i in range(2,2+n):
ans*=i
print(ans-n-1)
for i in range(n+1,1,-1):
print(i)
| p00993 |
<H1>Problem D : Numbers </H1>
<p>
<i>n</i> が与えられるので、<i>n</i> 個の連続した正の整数を求めよ。
ただしすべての数が、1とその数自身以外の約数をもたなくてはならない。
</p>
<H2>Input</H2>
<p>
入力は以下のフォーマットで与えられる。
</p>
<pre>
<i>n</i>
</pre>
<p>
入力は以下の制約を満たす。<br>
1 ≤ <i>n</i> ≤ 1,500
</p>
<h2>Output</h2>
<p>
最初の行に、あなたが選んだ連続した<i>n</i> 個の正の整数の中で一番小さいものを出力せよ。<br>
2行目... | 2
| 8
2
3
| 25,232 |
s361695182 | p00993 | u220324665 | 1492176569 | Python | Python | py | Accepted | 10 | 6292 | 84 | from math import*
n=input()+1
a=factorial(n)
print a+2
for i in range(2,n+1):print i | p00993 |
<H1>Problem D : Numbers </H1>
<p>
<i>n</i> が与えられるので、<i>n</i> 個の連続した正の整数を求めよ。
ただしすべての数が、1とその数自身以外の約数をもたなくてはならない。
</p>
<H2>Input</H2>
<p>
入力は以下のフォーマットで与えられる。
</p>
<pre>
<i>n</i>
</pre>
<p>
入力は以下の制約を満たす。<br>
1 ≤ <i>n</i> ≤ 1,500
</p>
<h2>Output</h2>
<p>
最初の行に、あなたが選んだ連続した<i>n</i> 個の正の整数の中で一番小さいものを出力せよ。<br>
2行目... | 2
| 8
2
3
| 25,233 |
s865809159 | p00993 | u220324665 | 1492176701 | Python | Python | py | Accepted | 10 | 6268 | 77 | import math
n=input()
print math.factorial(n+1)+2
for i in range(n):print i+2 | p00993 |
<H1>Problem D : Numbers </H1>
<p>
<i>n</i> が与えられるので、<i>n</i> 個の連続した正の整数を求めよ。
ただしすべての数が、1とその数自身以外の約数をもたなくてはならない。
</p>
<H2>Input</H2>
<p>
入力は以下のフォーマットで与えられる。
</p>
<pre>
<i>n</i>
</pre>
<p>
入力は以下の制約を満たす。<br>
1 ≤ <i>n</i> ≤ 1,500
</p>
<h2>Output</h2>
<p>
最初の行に、あなたが選んだ連続した<i>n</i> 個の正の整数の中で一番小さいものを出力せよ。<br>
2行目... | 2
| 8
2
3
| 25,234 |
s627241825 | p00993 | u220324665 | 1492177043 | Python | Python | py | Accepted | 10 | 6268 | 77 | import math;n=input();print math.factorial(n+1)+2
for i in range(n):print i+2 | p00993 |
<H1>Problem D : Numbers </H1>
<p>
<i>n</i> が与えられるので、<i>n</i> 個の連続した正の整数を求めよ。
ただしすべての数が、1とその数自身以外の約数をもたなくてはならない。
</p>
<H2>Input</H2>
<p>
入力は以下のフォーマットで与えられる。
</p>
<pre>
<i>n</i>
</pre>
<p>
入力は以下の制約を満たす。<br>
1 ≤ <i>n</i> ≤ 1,500
</p>
<h2>Output</h2>
<p>
最初の行に、あなたが選んだ連続した<i>n</i> 個の正の整数の中で一番小さいものを出力せよ。<br>
2行目... | 2
| 8
2
3
| 25,235 |
s101680760 | p00993 | u462831976 | 1492799257 | Python | Python3 | py | Accepted | 30 | 7800 | 317 | # -*- coding: utf-8 -*-
import sys
import os
import math
n = int(input())
if n == 1:
# 4
print(4)
print(2)
elif n == 2:
# 8, 9
print(8)
print(4)
print(3)
else:
a = 1
for i in range(1, n + 2):
a *= i
print(a - n - 1)
for i in range(n + 1, 1, -1):
print(i) | p00993 |
<H1>Problem D : Numbers </H1>
<p>
<i>n</i> が与えられるので、<i>n</i> 個の連続した正の整数を求めよ。
ただしすべての数が、1とその数自身以外の約数をもたなくてはならない。
</p>
<H2>Input</H2>
<p>
入力は以下のフォーマットで与えられる。
</p>
<pre>
<i>n</i>
</pre>
<p>
入力は以下の制約を満たす。<br>
1 ≤ <i>n</i> ≤ 1,500
</p>
<h2>Output</h2>
<p>
最初の行に、あなたが選んだ連続した<i>n</i> 個の正の整数の中で一番小さいものを出力せよ。<br>
2行目... | 2
| 8
2
3
| 25,236 |
s877488983 | p00993 | u231562319 | 1515511886 | Python | Python3 | py | Accepted | 30 | 5720 | 269 | def main():
num = 2
i = 3
for _ in range(1500//2):
num *= i
i += 2
n = int(input())
print(num+2)
for i in range(n):
a = i+2
if i%2 == 0:
a = 2
print(a)
if __name__ == '__main__':
main()
| p00993 |
<H1>Problem D : Numbers </H1>
<p>
<i>n</i> が与えられるので、<i>n</i> 個の連続した正の整数を求めよ。
ただしすべての数が、1とその数自身以外の約数をもたなくてはならない。
</p>
<H2>Input</H2>
<p>
入力は以下のフォーマットで与えられる。
</p>
<pre>
<i>n</i>
</pre>
<p>
入力は以下の制約を満たす。<br>
1 ≤ <i>n</i> ≤ 1,500
</p>
<h2>Output</h2>
<p>
最初の行に、あなたが選んだ連続した<i>n</i> 個の正の整数の中で一番小さいものを出力せよ。<br>
2行目... | 2
| 8
2
3
| 25,237 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.