input stringlengths 20 127k | target stringlengths 20 119k | problem_id stringlengths 6 6 |
|---|---|---|
H, W, M = list(map(int, input().split()))
hn = {}
wn = {}
flag = set()
for i in range(M):
h, w = list(map(int, input().split()))
if (h,w) not in flag:
if h in hn:
hn[h] += 1
else:
hn[h] = 1
if w in wn:
wn[w] += 1
else:
wn[w] = 1
flag.add((h,w))
hrank = ... | import sys
H, W, M = list(map(int, input().split()))
hn = [0]*H
wn = [0]*W
flag = set()
for i in range(M):
h, w = list(map(int, input().split()))
hn[h-1] += 1
wn[w-1] += 1
flag.add((h,w))
#hrank = sorted(hn, key=lambda t:-t[1])
#wrank = sorted(wn, key=lambda t:-t[1])
hmax = max(hn)
wmax = max... | p02580 |
#!/usr/bin/env python3
import collections
H, W, M = list(map(int, input().split()))
tate = []
yoko = []
S = []
for i in range(M):
h, w = list(map(int, input().split()))
tate.append(h-1)
yoko.append(w-1)
S.append([h-1, w-1])
tate = collections.Counter(tate)
yoko = collections.Counter(yo... | #!/usr/bin/env python3
import collections
H, W, M = list(map(int, input().split()))
tate = []
yoko = []
S = set()
for i in range(M):
h, w = list(map(int, input().split()))
tate.append(h-1)
yoko.append(w-1)
S.add((h-1, w-1))
tate = collections.Counter(tate)
yoko = collections.Counter(yo... | p02580 |
import math
while 1:
n = int(input())
if not n:
break
ans = 0
for p in range(1, int(math.sqrt(2*n))+1):
if 2*n % p ==0:
q = 2*n / p
if p>1 and (p+q)%2:
ans += 1
print(ans) | while 1:
n = int(input())
if not n:
break
ans = 0
p = 2
while p**2 <= 2*n:
if not 2*n % p:
if (p + 2*n/p) % 2:
ans += 1
p += 1
print(ans) | p01314 |
if __name__ == "__main__":
while True:
n = int(eval(input()))
if n ==0:break
nline = [i for i in range(1,n+1)]
count = 0
for i in range(n):
for j in range(i+1,n):
if sum(nline[i:j]) > n:break
if sum(nline[i:j]) == n:count ... | if __name__ == "__main__":
while True:
n = int(eval(input()))
if n ==0:break
count = 0
for i in range(1,n):
for j in range(i+1,n):
sum = (i+j)*(j-i+1)/2
if sum> n:break
if sum == n:count +=1
print(count) | p01314 |
import sys
from io import StringIO
import unittest
import math
def resolve():
x = int(input())
a = math.floor(x ** 0.2)
b5 = a ** 5 - x # マイナスになる
b = 0
right = 0
left = b5 - 10
if x == 1:
a = 0
b = -1
else:
while 1:
mid = (rig... | import sys
from io import StringIO
import unittest
import math
def resolve():
x = int(input())
a = math.floor(x ** 0.2) + 1
b5 = a ** 5 - x
if x == 1:
a = 0
b = -1
elif b5 == 0:
b = 0
else:
right = (10 ** 9)
left = -1 * (10 ** 9)
... | p02690 |
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import sys
def fib_bad(n):
if not n or n == 1:
return 1
return fib_bad(n - 2) + fib_bad(n - 1)
def fib_dp(n):
fib_list[:1] = [1, 1]
for i in range(2, n + 1):
fib_list[i] = fib_list[i - 2] + fib_list[i - 1]
return fib_... | #!/usr/bin/env python
# -*- coding: utf-8 -*-
import sys
# def fib_bad(n):
# if not n or n == 1:
# return 1
# return fib_bad(n - 2) + fib_bad(n - 1)
def fib_dp(n):
fib_list[:1] = [1, 1]
for i in range(2, n + 1):
fib_list[i] = fib_list[i - 2] + fib_list[i - 1]
ret... | p02233 |
def fibonacci(n):
if n == 0 or n == 1:
return 1
return fibonacci(n - 2) + fibonacci(n - 1)
print((fibonacci(int(eval(input()))))) | def fibonacci(f, n):
if n == 0 or n == 1:
f[n] = 1
return f[n]
if f[n]:
return f[n]
f[n] = fibonacci(f, n - 2) + fibonacci(f, n - 1)
return f[n]
n = int(eval(input()))
f = [None for i in range(n + 1)]
print((fibonacci(f, n))) | p02233 |
f=lambda n:f(n-1)+f(n-2)if n>1 else 1
print((f(int(eval(input())))))
| f=[1,1]
for _ in range(2,45):f+=[sum(f[-2:])]
print((f[int(eval(input()))]))
| p02233 |
#coding:UTF-8
def FN(n):
if n==0 or n==1:
return 1
else:
ans=FN(n-1)+FN(n-2)
return ans
if __name__=="__main__":
n=int(eval(input()))
ans=FN(n)
print(ans) | #coding:UTF-8
def FN(n):
if n==0 or n==1:
F[n]=1
return F[n]
if F[n]!=None:
return F[n]
F[n]=FN(n-1)+FN(n-2)
return F[n]
if __name__=="__main__":
n=int(eval(input()))
F=[None]*(n+1)
ans=FN(n)
print(ans) | p02233 |
n = int(input())
def fib(N):
if N in [0, 1]:
return 1
else:
return fib(N-1) + fib(N-2)
print(fib(n)) | n = int(input())
a = 1
b = 1
for i in range(n-1):
tmp = a
a = b
b += tmp
print(b) | p02233 |
def fib(n):
if n == 0:
return 1
elif n == 1:
return 1
else:
return fib(n - 1) + fib(n - 2)
n = eval(input())
print(fib(n)) | cache = {}
def fib(x):
if x in cache:
return cache[x]
elif x == 0 or x == 1:
return 1
else:
v = fib(x - 1) + fib(x - 2)
cache[x] = v
return v
x = eval(input())
print(fib(x)) | p02233 |
def fib(n):
if n==0 or n==1:
return 1
else:
return fib(n-1) + fib(n-2)
print((fib(int(eval(input())))))
| def fib(n):
if n ==0 or n == 1:
return 1
l = [0] * (n+1)
l[0] = 1
l[1] = 1
for i in range(2,n+1):
l[i] = l[i-2] + l[i-1]
return l[i]
print((fib(int(eval(input())))))
| p02233 |
def fib(n):
return 1 if n == 0 or n == 1 else fib(n - 1) + fib(n - 2)
print((fib(int(eval(input()))))) | def fib(n):
n1 = n2 = tmp = 1
for _ in range(n - 1):
tmp = n1 + n2
n1, n2 = n2, tmp
return tmp
print((fib(int(eval(input()))))) | p02233 |
def fib(n):
if n == 0 or n == 1:
return 1
return fib(n-1) + fib(n-2)
n = int(eval(input()))
print((fib(n))) | def fib(n, fib_table):
if n == 0 or n == 1:
return 1
if fib_table[n] != None:
return fib_table[n]
fib_table[n] = fib(n-1, fib_table) + fib(n-2, fib_table)
return fib_table[n]
n = int(eval(input()))
fib_table = [None]*(n+1)
fib_table[0] = 1
fib_table[1] = 1
print((fib(n, fi... | p02233 |
def fibonacci(n):
if n == 0 or n == 1:
return 1
else:
return fibonacci(n-1) + fibonacci(n-2)
if __name__ == '__main__':
n = int(eval(input()))
print((fibonacci(n))) | def fibonacci(n):
a, b = 1, 1
for i in range(n-1):
a, b = b, a+b
return b
if __name__ == '__main__':
n = int(eval(input()))
print((fibonacci(n))) | p02233 |
F_list = [1,1] + [None]*43
def fibo(n):
F=F_list[n]
if n==0 or n==1: return F
F = fibo(n-1)+fibo(n-2)
F_list[n]=F
return F
n = int(eval(input()))
print((fibo(n))) | F =[1,1] + [0 for i in range(44)]
n = int(eval(input()))
for i in range(2,n+1):
F[i]=F[i-1]+F[i-2]
print((F[n])) | p02233 |
# undo が出来るゲームは全て2手だけ見ればよい
ops = ["+", "*", "-", "&", "^", "|"]
numbers = ["1", "2", "3", "4", "5", "6", "7", "8", "9", "0"]
def check(x):
# +*
op = 0
for c in x:
if c in ops:
op += 1
if op >= 2:
return None
else:
op = 0
... | # undo が出来るゲームは全て2手だけ見ればよい
ops = ["+", "*", "-", "&", "^", "|"]
numbers = ["1", "2", "3", "4", "5", "6", "7", "8", "9", "0"]
def check(x):
# +*
op = 0
for c in x:
if c in ops:
op += 1
if op >= 2:
return None
else:
op = 0
... | p01624 |
# undo が出来るゲームは全て2手だけ見ればよい
ops = ["+", "*", "-", "&", "^", "|"]
numbers = ["1", "2", "3", "4", "5", "6", "7", "8", "9", "0"]
def check(x):
# +*
op = 0
for c in x:
if c in ops:
op += 1
if op >= 2:
return None
else:
op = 0
... | # undo が出来るゲームは全て2手だけ見ればよい
ops = ["+", "*", "-", "&", "^", "|"]
numbers = ["1", "2", "3", "4", "5", "6", "7", "8", "9", "0"]
def check(x):
# +*
op = 0
for c in x:
if c in ops:
op += 1
if op >= 2:
return None
else:
op = 0
... | p01624 |
def check(pattern):
for i in range(W - 2):
mask = 0b11 << i
if pattern & mask == mask:
return False
return True
def simulate(a1, pattern):
pat = [pattern & (1 << w) != 0 for w in range(W - 1)]
if a1 != W - 1 and pat[a1]:
return a1 + 1
elif a1 != 0 an... | def check(pat):
for i in range(W - 2):
mask = 0b11 << i
if pat & mask == mask:
return False
return True
def simulate(a1, pat):
if a1 != W - 1 and pat & 1 << a1 != 0:
return a1 + 1
elif a1 != 0 and pat & 1 << a1 - 1 != 0:
return a1 - 1
else:
... | p03222 |
H,W,K = list(map(int, input().split()))
MOD = 10**9 + 7
dp = [[0 for _ in range(W)] for _ in range(H+1)]
dp[0][0] = 1
ws = set()
for bit in range(1 << (W-1)):
if "11" in bin(bit):
continue
ws.add(bit)
for i in range(H):
for bit in ws:
# 高さi、左からj本目の縦棒にいるとき、どう移動するか。
... |
"""
AtCoder Beginner Contest 113 D - Number of Amidakuji
愚直に考えると、
・それぞれの縦棒の間に、横棒があるかないかの2通り。これがある高さhだけで、2^(W-1)通りある(横棒が2連続で続かないので、厳密には違うが)。
・これが高さH(最大100個分)あるので、(2^7)^100 とか?とにかく全探索は間に合わない。
メタ視点だが、W<=8なので、bitDPとかやれそう。
愚直解の何がよくないかというと、たとえば H = 6,W = 4 みたいなあみだくじについて考えるとして、
・この中で上から3段目までが同じでそれより下が異なるあみだくじと... | p03222 |
H, W, K = list(map(int, input().split()))
mod = 10 ** 9 + 7
F = [1, 1, 2, 3, 5, 8, 13, 21, 34]
inv_F = pow(F[W], mod - 2, mod)
P = [[0 for w in range(W + 2)] for h in range(H + 1)]
P[0][1] = 1
if W > 1:
for h in range(1, H + 1):
for w in range(1, W + 1):
P[h][w] = (P[h - 1][w - 1] * F... | H, W, K = list(map(int, input().split()))
mod = 10 ** 9 + 7
F = [1, 1, 2, 3, 5, 8, 13, 21, 34]
inv_F = pow(F[W], mod - 2, mod)
P = [[0 for w in range(W + 2)] for h in range(H + 1)]
P[0][1] = 1
for h in range(1, H + 1):
for w in range(1, W + 1):
P[h][w] = (P[h - 1][w - 1] * F[w - 2] * F[W - w] % mo... | p03222 |
H, W, K = list(map(int, input().split()))
mod = 10 ** 9 + 7
# 高さiにおいて左からj番目の棒にいる通り数
dp = [[0] * W for i in range(H + 1)]
dp[0][0] = 1
def pattern(w):
""" 幅wのあみだにおいて、validなものの通り数を返す """
# 例外処理
if w < 0:
return 1
cnt = 0
for i in range(2 ** w):
b = bin(2 ** w + i)[3... | from itertools import product
H, W, K = list(map(int, input().split()))
mod = 10 ** 9 + 7
# dp[i][j]:= 上からi番目, 左からj番目にいる通り数
dp = [[0] * W for i in range(H + 1)]
dp[0][0] = 1
def calc(x):
if x < 0:
return 1
ret = 0
for p in product(['0', '1'], repeat=x):
p = ''.join(p)
... | p03222 |
from itertools import product
H, W, K = list(map(int, input().split()))
mod = 10 ** 9 + 7
# dp[i][j]:= 上からi番目, 左からj番目にいる通り数
dp = [[0] * W for i in range(H + 1)]
dp[0][0] = 1
def calc(x):
if x < 0:
return 1
ret = 0
for p in product(['0', '1'], repeat=x):
p = ''.join(p)
... | H, W, K = list(map(int, input().split()))
MOD = 10 ** 9 + 7
def transition(w):
X = [1, 2, 3, 5, 8, 13, 21, 34]
if w >= 0:
return X[w]
else:
return 1
# h行w列に到達する方法
dp = [[0] * W for h in range(H + 1)]
dp[0][0] = 1
for h in range(H):
for w in range(W):
# 真下へ
... | p03222 |
from itertools import product
H, W, K = list(map(int, input().split()))
MOD = 10 ** 9 + 7
dp = [[0] * W for i in range(H + 1)]
dp[0][0] = 1
def calc(w):
if w <= 0:
return 1
ret = 0
for pattern in product([0, 1], repeat=w):
pattern = ''.join(list(map(str, pattern)))
i... | H, W, K = list(map(int, input().split()))
MOD = 10 ** 9 + 7
dp = [[0] * W for i in range(H + 1)]
dp[0][0] = 1
fib = [1, 2, 3, 5, 8, 13, 21, 34]
def calc(w):
if w < 0:
return 1
return fib[w]
for h in range(H):
for w in range(W):
dp[h + 1][w] = (dp[h + 1][w] + dp[h][w] * c... | p03222 |
import sys
def S(): return sys.stdin.readline().rstrip()
H,W,K = list(map(int,S().split()))
mod = 10**9+7
if W == 1:
print((1))
exit()
fib = [1,1,2,3,5,8,13,21] # fib[i] = i本の縦線に横線を引く方法の数(同じ高さ)
dp = [[0]*(W+1) for _ in range(H+1)] # dp[i][j] = i行目にjに達する横線の引き方
for i in range(H+1):
for... | import sys
sys.setrecursionlimit(10**7)
def I(): return int(sys.stdin.readline().rstrip())
def MI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def LI(): return list(map(int,sys.stdin.readline().rstrip().split())) #空白あり
def LI2(): return list(map(int,sys.stdin.readline().rstrip())) #空白なし
def ... | p03222 |
import sys
sys.setrecursionlimit(10**7)
def I(): return int(sys.stdin.readline().rstrip())
def MI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def LI(): return list(map(int,sys.stdin.readline().rstrip().split())) #空白あり
def LI2(): return list(map(int,sys.stdin.readline().rstrip())) #空白なし
def ... | import sys
def MI(): return list(map(int,sys.stdin.readline().rstrip().split()))
H,W,K = MI()
mod = 10**9+7
if W == 1:
print((1))
exit()
fib = [1,1,2,3,5,8,13,21] # fib[i] = i本のあみだくじの、ある列に横線を引く方法の数
dp = [[0]*(W+1) for _ in range(H+1)] # dp[i][j] = i段横線を引いたときに1からKに至るような横線の引き方
dp[0][1] = 1
for... | p03222 |
H,W,K=list(map(int,input().split()))
fibo=[1,1,2]
for i in range(W):
fibo.append(fibo[-1]+fibo[-2])
mod=1000000007
def f(H,K):
if H==0:
if K==1:
return 1
else:
return 0
else:
if K==0 or K==W+1:
return 0
else:
... | H,W,K=list(map(int,input().split()))
fibo=[1,1,2]
for i in range(W):
fibo.append(fibo[-1]+fibo[-2])
mod=1000000007
f=[[1 if i==1 else 0 for i in range(W+2)]]
for i in range(H):
for j in range(W):
f.append([(f[-1][j]*fibo[j-1]*fibo[W-j]+f[-1][j-1]*fibo[j-2]*fibo[W-j]\
... | p03222 |
import sys
MOD = 10 ** 9 + 7
h, w, k = list(map(int, sys.stdin.readline().split()))
def main():
ok = []
for i in range(2 ** (w - 1)):
prev = False
for j in range(w-1):
if i >> j & 1:
if prev:
break
else:
... | import sys
MOD = 10 ** 9 + 7
h, w, k = list(map(int, sys.stdin.readline().split()))
def main():
if w == 1:
return 1
ok = []
for i in range(2 ** (w - 1)):
prev = False
for j in range(w-1):
if i >> j & 1:
if prev:
... | p03222 |
MOD = 10**9 + 7
H, W, K = list(map(int, input().split()))
pats = []
for pat in range(1<<(W-1)):
for i in range(W-2):
if pat & (1<<i) and pat & (1<<(i+1)):
break
else:
pats.append(pat*2)
dp = [[0]*W for _ in range(H+1)]
dp[0][0] = 1
for i in range(H):
for j in ra... | MOD = 10**9 + 7
H, W, K = list(map(int, input().split()))
fibs = [0, 1, 1, 2, 3, 5, 8, 13, 21, 34]
def getFib(i):
return fibs[i+2]
numLs, numCs, numRs = [0]*W, [0]*W, [0]*W
for j in range(W):
numCs[j] = getFib(j-1) * getFib(W-1-j-1)
numLs[j] = getFib(j-2) * getFib(W-1-j-1)
numRs[j] = getF... | p03222 |
H, W, K = list(map(int, input().split()))
W2 = W-1
c = [0] * (W2+1)
cnt = 0
MOD = 10**9 + 7
for bit in range(1 << W2):
s0 = bit&1
flg=True
for i in range(1, W2):
if (bit>>i)&1 and s0 == 1:
flg = False
break
s0 = (bit>>i)&1
if flg:
cnt += 1
... | H, W, K = list(map(int, input().split()))
MOD, p, cnt = 10**9+7, [0]*W, 0
for bit in range(1<<(W-1)):
s0 = bit&1
flg=True
for w in range(1, W-1):
if (bit>>w)&1 and s0 == 1:flg=False; break
s0 = (bit>>w)&1
if flg:
cnt += 1
for w in range(W - 1):
if (... | p03222 |
mod = 10**9+7
h,w,k = list(map(int,input().split()))
k = k-1
dp = [0]*1000 #dp[i]=i個縦棒がある時の横棒の引き方
dp[0]=1
dp[1]=1
dp[2]=2
for i in range(3,1000):
dp[i] = (dp[i-1]+dp[i-2])%mod
#i-1とi番目に横棒を引かないとき、横棒の置き方は1からi-1番目の置き方と同じ
#i-1とi番目に横棒を引くとき、横棒の置き方は1からi-2番目の置き方と同じ(i-1とi-2の間には置けないから)
#→iの横棒の置き方はf(i-1)+f(... | mod = 10**9+7
h,w,k = list(map(int,input().split()))
fibonacchi =[1, 1, 2, 3, 5, 8, 13, 21, 34]
dp = [[0] * (w + 1) for _ in range(h + 1)]
dp[0][1] = 1
for i in range(h):
for j in range(w+1):
#dp[i][j]からdp[i+1][j-1]に遷移する条件
#jとj-1の間に横棒がある&j-1とj-2の間、j+1とjの間に横棒がない
#この置き方は
#(縦棒1から縦棒j-2までの横棒の置き... | p03222 |
import itertools
h, w, k = list(map(int, input().split()))
if w == 1:
print((1))
exit()
mod = 10**9 + 7
path = [[i, i+1] for i in range(w-1)]
DP = [[0]*(h+1) for _ in range(w)]
DP[0][0] = 1
for height in range(h):
for pos in range(w):
down_unable = {pos}
left_unable = {... | import itertools
h, w, k = list(map(int, input().split()))
DP = [0] * w
DP[0] = 1
mod = 10**9 + 7
patterns = []
for line_count in range(w):
candidates = itertools.combinations(list(range(w-1)), line_count)
for pattern in candidates:
usable = True
prev = 10
for nu... | p03222 |
l=[[] for i in range(9)]
l[1]=[""]
l[2]=["0","1"]
for i in range(3,9):
for s in l[i-1]:
l[i].append("0"+s)
if s[0]!="1":
l[i].append("1"+s)
mod=1000000007
s=input().split()
h,w,k=int(s[0]),int(s[1]),int(s[2])
res=[[0]*(w) for i in range(h+1)]
res[0][0]=1
for i in range(h):... | l=[[] for i in range(9)]
l[1]=[""]
l[2]=["0","1"]
for i in range(3,9):
for s in l[i-1]:
l[i].append("0"+s)
if s[0]!="1":
l[i].append("1"+s)
mod=1000000007
s=input().split()
h,w,k=int(s[0]),int(s[1]),int(s[2])
dp=[[0]*(w) for i in range(h+1)]
dp[0][0]=1
for i in range(h):
... | p03222 |
H,W,K=list(map(int,input().split()))
mod=10**9+7
fib=[1,1,2,3,5,8,13,21]
from functools import lru_cache
@lru_cache(maxsize=None)
def dfs(cur,now):
if cur==H:
if now==K:
return 1
else:
return 0
elif now==1:
if W==1:
return dfs(cur+1,1)... | H,W,K=list(map(int,input().split()))
mod=10**9+7
fib=[1,1,2,3,5,8,13,21]
memo=[[None]*W for _ in range(H+1)]
def dfs(cur,now):
if cur==H:
if now==K:
return 1
else:
return 0
elif now==1:
if W==1:
if memo[cur+1][0]==None:
mem... | p03222 |
MOD = 10 ** 9 + 7
H, W, K = list(map(int, input().split()))
K -= 1
# 0-indexed
dp = [[0 for _ in range(W)] for _ in range(H + 1)]
dp[0][0] = 1
# dp[h][k]
# h段のあみだくじで横線kに到達する本数
for h in range(H):
# h: 移動前の高さ
for b in range(1 << (W - 1)):
# 各段はW - 1箇所の横線配置位置をもつ
if '11' in bin(b... | def f(n):
# 縦線n本で構成できる横線の組み合わせ
if n <= 1: return 1
return f(n - 1) + f(n - 2)
MOD = 10 ** 9 + 7
H, W, K = list(map(int, input().split()))
K -= 1
# 0-indexed
dp = [[0 for _ in range(W)] for _ in range(H + 1)]
dp[0][0] = 1
# dp[h][k]
# h段のあみだくじで横線kに到達する本数
for h in range(H):
# h: 移動前... | p03222 |
mod = 10 ** 9 + 7
H, W, K = list(map(int, input().split()))
K -= 1
dp = [0] * W
dp[0] = 1
ndp = [0] * W
for r in range(H):
for i in range(1 << (W - 1)):
if '11' in bin(i): continue
perm = [i for i in range(W)]
for j in range(W - 1):
if (i >> j) & 1:
pe... | mod = 10 ** 9 + 7
h, w, k = list(map(int, input().split()))
k -= 1
dp = [0] * w
dp[0] = 1
ndp = [0] * w
for _ in range(h):
for bits in range(1 << w - 1):
if '11' in bin(bits): continue
to = list(range(w))
for i in range(w - 1):
if (bits >> i) & 1:
... | p03222 |
h,w,kk = list(map(int,input().split()))
dp = [[[] for j in range(w)] for i in range(h+1)]
# dp[i][j]
# 高さiにおいて点jに行き得る通り数
for i in range(h+1):
for j in range(w):
dp[i][j] = 0
dp[0][0]=1
mod = 1000000007
for i in range(1,h+1):
for j in range(1<<(w-1)):
yoko = [... | mod = 10**9+7
h,w,k = list(map(int,input().split()))
dp =[[0]*w for _ in range(h+1)]
dp[0][0]=1
fibo=[1]*10
for i in range(2,10):
fibo[i] = fibo[i-2]+fibo[i-1]
for i in range(1,h+1):
for j in range(w):
dp[i][j] = dp[i-1][j]*fibo[j]*fibo[w-j-1]%mod
if(j>0):
... | p03222 |
# -*- coding: utf-8 -*-
H, W, K = list(map(int,input().split()))
fibonacci = [1,1,2,3,5,8,13,21] # W <= 8なのでこれだけでいい
Amida = [ [0] * W for h in range(H+1)]
for h in range(H+1):
if W == 1:
break
for w in range(W):
if h == 0:
if w == 0:
Amida[h][w] = 1
else:
break
elif w == 0:
... | H, W, K = list(map(int,input().split()))
mod = 1000000007
fibonacci = [1,1,2,3,5,8,13,21] # W <= 8なのでこれだけでいい
Amida = [ [0] * W for h in range(H+1)]
for h in range(H+1):
if W == 1:
break
for w in range(W):
if h == 0:
if w == 0:
Amida[h][w] = 1
else:
break
elif w == 0:
Amida... | p03222 |
#!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, ... | #!usr/bin/env python3
from collections import defaultdict, deque
from heapq import heappush, heappop
from itertools import permutations, accumulate
import sys
import math
import bisect
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS():return [lis... | p03222 |
import sys
sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))
H, W, K = lr()
MOD = 10 ** 9 + 7
dp = [[0] * W for _ in range(H+1)]
dp[0][0] = 1
ladder = [[0] * 2 for _ in range(15)] #あえて多めに用意
ladder[1][0] = 1
for i in range(2, 9):
ladder[i][0] =... | # coding: utf-8
import sys
sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))
MOD = 10 ** 9 + 7
H, W, K = lr()
cases = [1] * 10 # 縦棒i本で何通りの横棒の書き方があるか(0本含む)
cases[-1] = 0
for i in range(2, 9):
cases[i] = cases[i-2] + cases[i-1]
dp = [0] * W
... | p03222 |
a,b,c=list(map(int,input().split()))
e=0
f=[[1,1]]
k=[[1,1,1],[2,1,1,1,2],[3,2,2,1,2,2,3],[5,3,3,2,4,2,3,3,5],[8,5,5,3,6,4,6,3,5,5,8],[12,8,8,5,10,6,9,6,10,5,8,8,12],[21,13,13,8,16,10,15,9,15,10,16,8,13,13,21]]
if b==1:
print((1))
else:
d=k[b-2]
for i in range(0,a):
l=len(f)
for j ... | a,b,c=list(map(int,input().split()))
s=[[0]*b for i in range(a+1)]
s[0][0]=1
k=[[1,1,1],[2,1,1,1,2],[3,2,2,1,2,2,3],[5,3,3,2,4,2,3,3,5],[8,5,5,3,6,4,6,3,5,5,8],[13,8,8,5,10,6,9,6,10,5,8,8,13],[21,13,13,8,16,10,15,9,15,10,16,8,13,13,21]]
if b==1:
print((1))
elif c-a>=2:
print((0))
else:
d=k[b-2]... | p03222 |
# ABC 113 D
MOD = 7 + 10**9
H, W, K = list(map(int,input().split()))
dp = [[0 for k in range(W)] for l in range(H+1)]
dp[0][0] = 1
for i in range(H):
for j in range(W):
for k in range(1<<(W-1)):
f = 1
for l in range(W-2):
if (k>>l)&1 and (k>>(l+1))&1:
... | MOD = 10**9 + 7
H, W, K = list(map(int,input().split()))
dp = [[0 for k in range(W)] for l in range(H+1)]
dp[0][0] = 1
A = [] # ありうる横棒のリスト
for b in range(2**(W-1)):
if "11" not in bin(b):
A.append(bin(b)[2:].zfill(W-1))
for k in range(H):
for e in A:
for i in range(W):
... | p03222 |
from collections import defaultdict
A = [1, 2, 3, 5, 8, 13, 21, 34]
MOD = 10**9 + 7
H, W, K = list(map(int, input().split()))
K -= 1
if W == 0:
print((1))
exit()
dp = [[0] * W for _ in range(H + 1)]
dp[0][0] = 1
for i in range(1, H + 1):
for j in range(i + 1):
for k in [-1, 0, 1]:
... | A = [1, 2, 3, 5, 8, 13, 21]
MOD = 10**9 + 7
H, W, K = list(map(int, input().split()))
if W == 0:
print((1))
exit()
dp = [[0] * W for _ in range(H + 1)]
dp[0][0] = 1
for i in range(1, H + 1):
for j in range(i + 1):
for k in [-1, 0, 1]:
if not 0 <= j + k < W: continue
... | p03222 |
import sys
stdin = sys.stdin
sys.setrecursionlimit(10**5)
def li(): return list(map(int, stdin.readline().split()))
def li_(): return [int(x)-1 for x in stdin.readline().split()]
def lf(): return list(map(float, stdin.readline().split()))
def ls(): return stdin.readline().split()
def ns(): return stdin.readl... | import sys
stdin = sys.stdin
sys.setrecursionlimit(10 ** 7)
def li(): return list(map(int, stdin.readline().split()))
def li_(): return [int(x) - 1 for x in stdin.readline().split()]
def lf(): return list(map(float, stdin.readline().split()))
def ls(): return stdin.readline().split()
def ns(): return stdin.r... | p03222 |
h, w, K = list(map(int, input().split()))
mod = 10**9+7
dp = [[0] * w for _ in range(h+1)]
dp[0][0] = 1
for i in range(1, h+1):
for j in range(w):
left, center, right = 0, 0, 0
for k in range(2**(w-1)):
invalid = False
for l in range(1, w-1):
i... | H, W, K = list(map(int, input().split()))
mod = 10**9 + 7
dp = [[0] * W for _ in range(H + 1)]
dp[0][0] = 1
def fib(n):
if n <= 1:
return 1
return fib(n-1) + fib(n-2)
for i in range(1, H+1):
for j in range(W):
left = j
right = W - j - 1
dp[i][j] = dp[i... | p03222 |
h,w,k=list(map(int,input().split()));p=[sum(('11'in str(bin(j)))^1for j in range(1<<i))for i in range(8)];d=[w*[0]for _ in[0]*-~h];d[0][0]=1
for i in range(h):
b=d[i]
for j in range(w):
t=u=D=0
if j:t=p[max(0,j-2)]*p[max(0,w-j-2)];D=b[j-1]*t
if j<w-1:u=p[max(0,j-1)]*p[max(0,w-j-3)];D+=b[j+1]*u
d[i+1][j... | h,w,k=list(map(int,input().split()))
p=[sum(('11'in str(bin(j)))^1for j in range(1<<i))for i in range(8)]
dp=[w*[0]for _ in[0]*-~h]
dp[0][0]=1
for i in range(1,h+1):
for j in range(w):
t=u=0
if j:
t=p[max(0,j-2)]*p[max(0,w-j-2)]
dp[i][j]+=dp[i-1][j-1]*t
if j... | p03222 |
H,W,K = list(map(int,input().split()))
K -= 1
MOD = 10**9+7
dp = [[0]*W for i in range(H+1)]
dp[0][0] = 1
for i in range(H):
for b in range(2**(W-1)):
if '11' in bin(b): continue
b *= 2
for j in range(W):
if b&(1<<j):
dp[i+1][j-1] += dp[i][j]
... | H,W,K = list(map(int,input().split()))
MOD = 10**9+7
if W == 1:
print((1))
exit()
dp = [[0]*W for i in range(H+1)]
dp[0][0] = 1
for i in range(H):
for b in range(2**(W-1)):
if '11' in bin(b): continue
b *= 2
for j in range(W):
if b&(1<<j):
... | p03222 |
H,W,K = list(map(int,input().split()))
amida = [0 for i in range(8)]
amida[0]=1
amida[1]=2
amida[2]=3
amida[3]=5
amida[4]=8
amida[5]=13
amida[6]=21
amida[7]=34
def amida_num(k,l):
return amida[max(k,0)]*amida[max(l,0)]
dp=[[0 for i in range(W)] for j in range(H+1)]
dp[0][0] = 1
if... | H,W,K=list(map(int,input().split()))
r = 10**9 + 7
dp=[[0 for i in range(W)] for j in range(H+1)]
dp[0][0]=1
num = [1,1,2,3,5,8,13,21]
if W!=1:
for i in range(H):
for j in range(W):
if j==0:
dp[i+1][j]=(num[W-1]*dp[i][j]+num[W-2]*dp[i][j+1])%r
elif... | p03222 |
import itertools
def amida_counter(H_i_amida_list):
counter = 0
for amida_bin in range(2**len(H_i_amida_list)):
if (("11" in format(amida_bin, "b")) == False):
counter += 1
return counter
def amida_number(left_amida, right_amida):
left_counter = amida_counter(left_ami... | import itertools
def amida_counter(H_i_amida_list):
counter = 0
for amida_bin in range(2**len(H_i_amida_list)):
if (("11" in format(amida_bin, "b")) == False):
counter += 1
return counter
def amida_number(left_amida, right_amida):
left_counter = amida_counter(left_ami... | p03222 |
h,w,k = list(map(int,input().split()))
honsu=w
a = 0
def amida(h,w):
global a
if h == 0 and w == k:
return 1
if h ==0:
return 0
if not(1<=w<=honsu):
return 0
com1 = fib(honsu-w+1)*fib(w-1)*amida(h-1,w-1)
com2 = fib(honsu-w+1)*fib(w)*amida(h-1,w)
com3 = fib(honsu-w)*fib(w)*a... | h,w,k = list(map(int,input().split()))
a=[[0]*w for i in range(h+1)]
fib_memo = {}
def fib(n):
if n < 3: return 1
if n not in fib_memo:
fib_memo[n] = fib(n-1) + fib(n-2)
return fib_memo[n]
for j in range(w):
a[0][j]=0
a[0][0]=1
for i in range(1,h+1):
for j in range(w):
... | p03222 |
H, W, K = [int(_) for _ in input().split()]
MOD = 1000000007
P = [""]
for i in range(W - 1):
Q = []
for p in P:
Q.append(p + "0")
if len(p) == 0 or p[-1] == "0":
Q.append(p + "1")
P = Q
rs = [1] + [0] * (W - 1)
for j in range(H):
nrs = [0] * W
for p i... | H, W, K = [int(_) for _ in input().split()]
MOD = 1000000007
pats = [[0]]
for i in range(1, W):
pats = [p + [i] for p in pats] + [p[:-1] + [i, i - 1] for p in pats if p[-1] == i - 1]
rs = [1] + [0] * (W - 1)
for j in range(H):
rs = [sum(rs[p[i]] for p in pats) % MOD for i in range(W)]
print(... | p03222 |
h, w, k = list(map(int, input().split()))
dp = [1] + [0] * (w - 1)
mod = 1000000007
for _ in range(h):
newdp = [0] * w
for b in range(1 << (w - 1)):
valid = True
for i in range(w - 1):
if (b >> i) & 3 == 3:
valid = False
if valid:
for i ... | h, w, k = list(map(int, input().split()))
dp = [1] + [0] * (w - 1)
mod = 1000000007
def mul(a, b):
newmatrix = [[0] * w for _ in range(w)]
for i in range(w):
for j in range(w):
newmatrix[i][j] = sum(a[i][k] * b[k][j] for k in range(w)) % mod
return newmatrix
matrix = [[0] * ... | p03222 |
h, w, k = list(map(int, input().split()))
dp = [0] * w
mod = 10 ** 9 + 7
dp[0] = 1
for i in range(h):
next = [0] * w
for bit in range(1 << w - 1):
ok = True
for j in range(w - 2):
if bit >> j & 1 and bit >> j + 1 & 1:
ok = False
if ok:
... | h, w, k = list(map(int, input().split()))
dp = [0] * w
mod = 10 ** 9 + 7
comb = []
for bit in range(1 << w - 1):
ok = True
for j in range(w - 2):
if bit >> j & 1 and bit >> j + 1 & 1:
ok = False
if ok:
comb.append(bit)
dp[0] = 1
for i in range(h):
next = [0] ... | p03222 |
h,w,k = list(map(int, input().split()))
# (上から, 左右から)の通り数
memo = [[0]*w for i in range(h+1)]
for i in range(0, w):
memo[0][i] = 0
memo[0][0] = 1
# print(memo)
for i in range(1, h+1):
for j in range(0, 1 << (w-1)):
skip = False
for l in range(w-2):
skip = skip or ((j >>... | h,w,k = list(map(int, input().split()))
memo = [[0]*w for i in range(h+1)]
for i in range(0, w):
memo[0][i] = 0
memo[0][0] = 1
for i in range(1, h+1):
for j in range(0, 1 << (w-1)):
skip = False
for l in range(w-2):
skip = skip or ((j >> l) & 1 and (j >> (l+1)) & 1)
... | p03222 |
MOD=10**9+7
H,W,K=list(map(int,input().split()))
dp=[[0]*W for i in range(H+1)]
dp[0][0]=1
for i in range(1,H+1):
for k in range(W):
l,c,r=0,0,0
for bit in range(2**(W-1)):
ok=True
for t in range(W-2):
if (bit>>t&1) and (bit>>(t+1)&1):
... | MOD=10**9+7
def isvalid(bit):
for t in range(W-2):
if (bit>>t&1) and (bit>>(t+1)&1):
return False
return True
H,W,K=list(map(int,input().split()))
dp=[[0]*W for i in range(H+1)]
dp[0][0]=1
for i in range(1,H+1):
for k in range(W):
l,c,r=0,0,0
for bit in ... | p03222 |
import sys
mod = pow(10, 9) + 7
def mul(a, b):
return ((a % mod) * (b % mod)) % mod
def cmb(n, r, mod):
if ( r<0 or r>n ):
return 0
r = min(r, n-r)
return g1[n] * g2[r] * g2[n-r] % mod
NNN = (10**5) * 2
g1 = [1, 1]
g2 = [1, 1]
inverse = [0, 1]
for i in range( 2, NNN + 1 ):
... | import sys
mod = pow(10, 9) + 7
def mul(a, b):
return ((a % mod) * (b % mod)) % mod
def cmb(n, r, mod):
if ( r<0 or r>n ):
return 0
r = min(r, n-r)
return g1[n] * g2[r] * g2[n-r] % mod
NNN = (10**2)
g1 = [1, 1]
g2 = [1, 1]
inverse = [0, 1]
for i in range( 2, NNN + 1 ):
g1... | p03222 |
# 解説と下記を参考に作成
# https://atcoder.jp/contests/abc113/submissions/15821617
# import sys
# sys.setrecursionlimit(10 ** 6)
# import bisect
# from collections import deque
# from decorator import stop_watch
#
#
# @stop_watch
def solve(H, W, K):
mod = 10 ** 9 + 7
dp = [[0] * W for _ in range(H + 1)]
... | # 解説と下記を参考に作成
# https://atcoder.jp/contests/abc113/submissions/15821617
# import sys
# sys.setrecursionlimit(10 ** 6)
# import bisect
# from collections import deque
# from decorator import stop_watch
#
#
# @stop_watch
def solve(H, W, K):
mod = 10 ** 9 + 7
dp = [[0] * W for _ in range(H + 1)]
d... | p03222 |
import sys
read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60
MOD = 1000000007
def main():
H, W, K = list(map(int, readline().split()))
dp = [0] * W
dp[0] = 1
for _ in range(H):
dp, dp_prev = [0] ... | import sys
read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60
MOD = 1000000007
def main():
H, W, K = list(map(int, readline().split()))
dp = [0] * W
dp[0] = 1
for _ in range(H):
dp, dp_prev = [0] ... | p03222 |
K, S = list(map(int, input().split()))
ans = 0
for x in range(K + 1):
for y in range(K + 1):
z = S - x - y
if z >= 0 and z <= K:
ans += 1
print(ans)
| K, S = list(map(int, input().split()))
cnt = 0
for i in range(K+1):
for j in range(K+1):
x = S - i - j
if 0 <= x <= K:
cnt += 1
print(cnt)
| p03835 |
K, S = list(map(int, input().split()))
count = 0
for X in range(K + 1):
if X > S:
break
for Y in range(min(K, S - X) + 1):
if Y < 0:
continue
if X + Y > S:
break
Z = S - X - Y
if X <= K and Y <= K and Z <= K:
count += 1
pri... | K, S = list(map(int, input().split()))
count = 0
for X in range(min(S + 1, K + 1)):
for Y in range(min(S - X + 1, K + 1)):
if S - X - Y <= K:
count += 1
print(count)
| p03835 |
K,S = list(map(int,input().split()))
g = 0
for x in range(0,K+1):
for y in range(x,K+1):
for z in range(y,K+1):
if x+y+z == S:
if x == y == z:g += 1
elif x == y or y == z:g += 3
else:g += 6
print(g) | K,S = list(map(int,input().split()))
t = 0
#c = 0
for x in range(max(0,S-2*K),min(S//3+1,K+1)):
if S-x > 2 * K:
pass
else:
for y in range(max(x,S-x-K),min((S-x)//2+1,K+1)):
#c += 1
z = S - x - y
if z < y:
#print('pass')
... | p03835 |
k, s = list(map(int, input().split()))
count = 0
sz_list = []
for i in range(k+1):
sz_list.append(s-i)
for x in range(k+1):
for y in range(k+1):
s = x +y
if s in sz_list:
count+=1
print(count) | k, s = list(map(int, input().split()))
count = 0
for x in range(k+1):
for y in range(k+1):
z = s - x - y
if z >= 0 and z <= k:
count+=1
print(count)
| p03835 |
#入力
K, S = list(map(int, input().split()))
#問題文よりX, Y, Zの最大値はKである
X = list(range(K+1))
Y = list(range(K+1))
Z = list(range(K+1))
#フラグ設定
flag = 0
#全探索
for x in X:
for y in Y:
for z in Z:
#条件
if x+y+z==S:
flag += 1
#出力
print(flag) | #入力
K, S = list(map(int, input().split()))
#問題文よりX, Y, Zの最大値はKであるため、各値の最大値はKである
X = list(range(K+1))
Y = list(range(K+1))
#フラグ設定
flag = 0
#全探索
for x in X:
for y in Y:
#条件に合うzの値を算出
z = S - x - y
if z<=K and z>=0: #上で求めたzの値に問題文からFilterを掛ける
flag += 1
#出力
prin... | p03835 |
k, s = list(map(int, input().split()))
ans = 0
for i in range(k+1):
for j in range(k+1):
for m in range(k+1):
if i + j + m == s:
ans += 1
print(ans)
| k, s = list(map(int, input().split()))
ans = 0
for i in range(k+1):
for j in range(k+1):
if (i + j <= s) and (s - i - j <= k):
ans += 1
print(ans) | p03835 |
count=0
k,s=list(map(int,input().split()))
for i in range(k+1):
for j in range(k+1):
for m in range(k+1):
if i+j+m==s:
count+=1
print(count) | count=0
k,s=list(map(int,input().split()))
for i in range(k+1):
for j in range(k+1):
if s-k<=i+j<=s:
count+=1
print(count) | p03835 |
K,S=list(map(int,input().split()))
count=0
for x in range(K+1):
for y in range(K+1):
for z in range(K+1):
if x+y+z == S:
count+=1
print(count) | K,S=list(map(int,input().split()))
count=0
for x in range(K+1):
for y in range(K+1):
z=S-x-y
if z>=0 and z<=K:
count+=1
print(count) | p03835 |
import sys
def input(): return sys.stdin.readline().strip()
k,s=list(map(int,input().split()))
c=0
for x in range(k+1):
if x + 2 * k < s:
continue
for y in range(k+1):
if x + y > s:
continue
if x + y + k < s:
continue
c += 1
print(c) | import sys
def input(): return sys.stdin.readline().strip()
k,s=list(map(int,input().split()))
c=0
for x in range(max(0,s-2*k),k+1):
for y in range(max(0,s-x-k),min(k,s-x)+1):
c += 1
print(c) | p03835 |
k, s = list(map(int, input().split()))
ans = 0
for x in range(k + 1):
for y in range(k + 1):
for z in range(k + 1):
if (x + y + z == s):
ans += 1
print(ans)
| k, s = list(map(int, input().split()))
ans = 0
for x in range(k + 1):
for y in range(k + 1):
if (x + y <= s and s - (x + y) <= k):
ans += 1
print(ans)
| p03835 |
K,S=list(map(int,input().split()))
count=0
for i in range(K+1):
for j in range(K+1):
for m in range(K+1):
if i+j+m==S:
count+=1
print(count) | K,S=list(map(int,input().split()))
count=0
for i in range(K+1):
for j in range(K+1):
if 0 <= S-i-j <= K:
count += 1
print(count) | p03835 |
K,S=list(map(int,input().split()))
count=0
for i in range(K+1):
for j in range(K+1):
if 0 <= S-i-j <= K:
count += 1
print(count) | k,s=list(map(int,input().split()));count=0
for i in range(0,k+1):
for j in range(0,k+1):
if 0<=s-(i+j)<=k: count+=1
print(count) | p03835 |
n,k=list(map(int,input().split()))
ans=0
for i in range(n+1):
for j in range(n+1):
for l in range(n+1):
if i+j+l==k:
ans+=1
print(ans)
| n,k=list(map(int,input().split()))
ans=0
for i in range(n+1):
for j in range(n+1):
if 0<=k-i-j<=n:
ans+=1
print(ans)
| p03835 |
K , S = list(map(int, input().split()))
x , y , z , cnt = 0 , 0 , 0 , 0
A = K + 1
if K * 3 == S:
cnt = 1
else :
for i in range(A):
x = i
for j in range(A):
y = j
for k2 in range(A) :
z = k2
if x + y + z == S:
... | K , S = list(map(int, input().split()))
x , y , z , cnt = 0 , 0 , 0 , 0
A = K + 1
if K * 3 == S:
cnt = 1
else :
for i in range(A):
for j in range(A):
if S - (i + j) <= K :
if 0 <= S - (i + j):
cnt += 1
print(cnt)
| p03835 |
K,S=list(map(int,input().split()))
count=0
for x in range(K+1):
for y in range(K+1):
for z in range(K+1):
if x+y+z==S:
count+=1
print(count) | K,S=list(map(int,input().split()))
count=0
for x in range(K+1):
for y in range(K+1):
if 0<=S-x-y<=K:
count+=1
print(count) | p03835 |
[K,S] = list(map(int,input().split()))
count=0
for X in range(K+1):
for Y in range(K+1):
for Z in range(K+1):
if X+Y+Z==S:
count+=1
print(count) | [K,S] = list(map(int,input().split()))
count=0
for X in range(K+1):
for Y in range(K+1):
Z = S - X - Y
if Z in range(K+1):
count+=1
print(count) | p03835 |
from sys import stdin
n = input().split(' ')
c = 0
K = int(n[0])
S = int(n[1])
for i in range(int(K)+1):
for j in range(int(K)+1):
if(S-(i+j) <= K and S>=i+j):
c+=1
print(c) | k, s = list(map(int, input().split()))
ans = 0
for i in range(k + 1):
for j in range(k + 1):
if 0 <= s - i - j <= k:
ans +=1
print(ans) | p03835 |
# -*- coding: utf-8 -*-
K, S = list(map(int, input().split()))
cnt = 0
for X in range(0, K+1):
for Y in range(0, K+1):
if 0<=S-X-Y and S-X-Y<=K:
cnt += 1
print(cnt) | # -*- coding: utf-8 -*-
k, s = list(map(int,input().split()))
cnt = 0
for x in range(k + 1):
for y in range(k + 1):
z = s - x - y
if (0 <= z <= k):
cnt += 1
print(cnt) | p03835 |
K, S = list(map(int, input().rstrip().split()))
n = 0
for x in range(K + 1):
for y in range(K + 1):
if x + y > S:
break
for z in range(K + 1):
if x + y + z > S:
break
if (x + y + z) == S:
n += 1
print(n)
| K, S = list(map(int, input().rstrip().split()))
n = 0
for x in range(K + 1):
for y in range(K + 1):
z = S - x - y
if 0 <= z and z <= K:
n += 1
print(n)
| p03835 |
k, s = list(map(int, input().split()))
r = 0
for x in range(k + 1):
for y in range(k + 1):
z = s - x - y
if 0 <= z <= k and z + x + y == s:
r += 1
print(r)
| k, s = list(map(int, input().split()))
r = 0
for x in range(k + 1):
for y in range(0, min(s - x + 1, k + 1)):
z = s - x - y
if 0 <= z <= k and z + x + y == s:
r += 1
print(r)
| p03835 |
k,s=list(map(int,input().split()))
ans=0
if s<=k:
print(((s+1)*(s+2)//2))
exit()
for i in range(k+1):
for j in range(i,k+1):
for l in range(j,k+1):
if i+j+l==s:
if i==j and j==l:
ans+=1
elif i==j or j==l or l==i:
ans+=3
else:
ans+=6
pr... | k,s=list(map(int,input().split()))
ans=0
if s<=k:
print(((s+1)*(s+2)//2))
exit()
for i in range(k+1):
for j in range(k+1):
if 0<=s-i-j<=k:
ans+=1
print(ans)
| p03835 |
k,s=list(map(int,input().split()))
t=0
for i in range(k+1):
for j in range(k+1):
for l in range(k+1):
if i+j+l==s:
t+=1
print(t)
| k,s=list(map(int,input().split()))
t=0
for i in range(k+1):
for j in range(k+1):
l=s-i-j
if 0<=l<=k:
t+=1
print(t)
| p03835 |
k,s = list(map(int,input().split()))
cnt = 0
for x in range(s + 1):
for y in range(s + 1 - x):
if x <= k and y <= k and s - x - y <= k:
cnt += 1
print(cnt)
| k,s = list(map(int,input().split()))
cnt = 0
M = min(s + 1,k + 1)
for x in range(M):
for y in range(min(s + 1 - x,k + 1)):
if s - x - y <= k:
cnt += 1
print(cnt)
| p03835 |
k,s = list(map(int, input().split()))
cnt = 0
for x in range(k+1):
for y in range(k+1):
for z in range(k+1):
if x+y+z == s:
cnt += 1
print(cnt) | k,s = list(map(int, input().split()))
cnt = 0
for x in range(k+1):
for y in range(k+1):
z = s - x -y
if 0 <= z <= k:
cnt += 1
print(cnt) | p03835 |
K, S = list(map(int, input().strip().split(' ')))
cnt = 0
for X in range(0, K+1):
for Y in range(0, K+1):
for Z in range(0, K+1):
if X+Y+Z == S:
cnt += 1
print(cnt) | K, S = list(map(int, input().strip().split(' ')))
cnt = 0
if S < K:
for X in range(0, S+1):
cnt += (S-X+1)
else:
for X in range(0, K+1):
if (S-X) <= (2*K):
if (S-X) < K:
cnt += (S-X+1)
elif (S-X) > K:
Z = S-X-K
cnt += (K-Z+1)
else:
cnt += (K+1)
print(cnt) | p03835 |
#全探索(多分TLE)
K, S = list(map(int, input().split()))
ans = 0
for i in range(K+1):
for j in range(K+1):
for k in range(K+1):
if i+j+k == S:
ans += 1
print(ans) | K, S = list(map(int, input().split()))
ans = 0
for x in range(K+1):
for y in range(K+1):
if S >= x+y and S-(x+y) <= K:
ans += 1
print(ans) | p03835 |
k, s = list(map(int, input().split()))
count = 0
for y in range(k+1):
for x in range(k+1):
z = s - x - y
if 0 <= z <= k:
count += 1
print(count) | k, s = list(map(int, input().split()))
count = 0
for x in range(k+1):
for y in range(k+1):
z = s-x-y
if 0 <= z <= k:
count += 1
print(count) | p03835 |
# Me
def resolve(k, s):
c = 0
for x in range(0, k+1):
for y in range(0, k+1):
for z in range(0, k+1):
if x + y + z == s:
c += 1
return c
k, s = list(map(int, input().split()))
print((resolve(k, s)))
| # Me
def resolve(k, s):
c = 0
for x in range(0, k+1):
for y in range(0, k+1):
if 0 <= s - (x + y) <= k:
c += 1
return c
k, s = list(map(int, input().split()))
print((resolve(k, s)))
| p03835 |
import sys
from pprint import pprint
k, s = list(map(int, sys.stdin.readline().strip().split(" ")))
ans = 0
for x in range(k+1):
for y in range(k+1):
if 0 <= s - x - y <= k:
ans += 1
# print(x, y, s - x - y)
print(ans) | import sys
K, S = list(map(int, sys.stdin.readline().strip().split()))
N_MAX = min(K, S)
ans = 0
for i in range(N_MAX+1):
for j in range(N_MAX+1):
if 0 <= S - (i + j) <= K:
ans += 1
print(ans) | p03835 |
k,s=list(map(int,input().split()))
a=0
for i in range(k+1):
for j in range(k+1):
for l in range(k+1):
if i+j+l==s:
a+=1
print(a) | k,s=list(map(int,input().split()))
a=0
for i in range(k+1):
for j in range(k+1):
if 0<=s-i-j<k+1:
a+=1
print(a) | p03835 |
k, s = list(map(int,input().split(' ')))
count = 0
for x in range(k+1):
for y in range(k+1):
for z in range(k+1):
if x + y + z == s:
count += 1
print(count) | k, s = list(map(int,input().split(' ')))
count = 0
for x in range(k+1):
for y in range(k+1):
z = s - (x+y)
if 0 <= z and z <= k:
count += 1
print(count) | p03835 |
K, S = list(map(int, input().split()))
count = 0
for x in range(K+1):
for y in range(K+1):
for z in range(K+1):
if x + y + z == S:
count += 1
print(count) | K, S = list(map(int, input().split()))
count = 0
for x in range(K+1):
for y in range(K+1):
z = S - x - y
if 0<=z and z<=K:
count += 1
print(count) | p03835 |
k,s=list(map(int,input().split()))
counter=0
for x in range(k+1):
for y in range(k+1):
for z in range(k+1):
if x+y+z==s:
counter+=1
print(counter)
| k,s=list(map(int,input().split()))
counter=0
for x in range(k+1):
for y in range(k+1):
if 0<=s-x-y<=k:
counter+=1
print(counter)
| p03835 |
k, s = list(map(int, input().split()))
cnt = 0
for x in range(k + 1):
for y in range(k + 1):
z = s - x - y
if 0 <= z and z <= k:
cnt += 1
print(cnt) | k, s = list(map(int, input().split()))
cnt = 0
for x in range(k + 1):
for y in range(min(k + 1, s + 1 - x)):
z = s - x - y
if 0 <= z and z <= k:
cnt += 1
print(cnt) | p03835 |
K, S = [int(x) for x in input().split()]
dic = {}
for i in range(K + 1):
for j in range (K + 1):
r = S - i - j
if r in list(dic.keys()):
dic[r].append((i, j))
else:
dic[r] = [(i, j)]
ans = 0
for k in range(K + 1):
if k in list(dic.keys()):
... | K, S = [int(x) for x in input().split()]
ans = 0
for i in range(K + 1):
for j in range (K + 1):
r = S - i - j
if r <= K and r >= 0:
ans += 1
print(ans) | p03835 |
K, S = list(map(int, input().split(" ")))
count = 0
for x in range(K + 1):
for y in range(K + 1):
for z in range(K + 1):
ans = x + y + z
if S == ans:
count += 1
print(count) | K, S = list(map(int, input().split(" ")))
count = 0
for x in range(K + 1):
for y in range(K + 1):
if S - x - y >= 0 and S - x - y <= K:
count += 1
print(count) | p03835 |
#https://atcoder.jp/contests/abc051/tasks/abc051_b
# -*- coding: utf-8 -*-
K,S = list(map(int,input().split()))
ans = 0
for i in range(K+1):
for j in range(K+1):
for k in range(K+1):
if i+j+k == S: ans +=1
print(ans) | #https://atcoder.jp/contests/abc051/tasks/abc051_b
# -*- coding: utf-8 -*-
K,S = list(map(int,input().split()))
ans = 0
for i in range(0,K+1):
for j in range(0,K+1):
z = S-i-j
if 0 <= z <= K: ans +=1
print(ans) | p03835 |
K, S = list(map(int, input().split()))
count = 0
K += 1
for x in range(K):
for y in range(K):
for z in range(K):
if S == x + y + z:
count += 1
print(count) | K, S = list(map(int, input().split()))
count = 0
for x in range(K+1):
for y in range(K+1):
z = S - x - y
if 0 <= z <= K:
count += 1
print(count)
| p03835 |
k,s = list(map(int,input().split()))
c = 0
for i in range(k+1):
for j in range(k+1):
for l in range(k+1):
if i+j+l == s:
c += 1
print(c) | k,s = list(map(int,input().split()))
c = 0
for y in range(k+1):
for z in range(k+1):
if 0 <= s-(y+z) <= k:
c += 1
print(c) | p03835 |
k, s = list(map(int, input().split()))
ans = 0
for x in range(s + 1):
for y in range(s - x + 1):
z = s - x - y
if x <= k and y <= k and z <= k:
ans += 1
print(ans) | k, s = list(map(int, input().split()))
ans = 0
for x in range(k+1):
for y in range(k+1):
z = (s-(x+y))
if 0 <= z and z <= k:
ans += 1
print(ans) | p03835 |
# -*- coding utf-8 -*-
k,s=list(map(int,input().split()))
ans=0
for x in range(k+1):
for y in range(k+1):
if 0<=s-x-y<=k:
ans+=1
print(ans)
| k,s=list(map(int,input().split()))
ans=0
for x in range(k+1):
for y in range(k+1):
if 0<=s-x-y<=k:
ans+=1
print(ans)
| p03835 |
n,s=list(map(int,input().split()))
ans=0
for i in range(n+1):
for j in range(n+1):
if s-i-j>-1 and s-i-j<n+1:
ans+=1
print(ans)
| n,s=list(map(int,input().split()))
ans=0
for i in range(n+1):
if s-i>n*2 or s-i<0:
continue
for j in range(n+1):
if -1<s-i-j<n+1:
ans+=1
print(ans)
| p03835 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.