description stringlengths 171 4k | code stringlengths 94 3.98k | normalized_code stringlengths 57 4.99k |
|---|---|---|
Quite recently a creative student Lesha had a lecture on trees. After the lecture Lesha was inspired and came up with the tree of his own which he called a k-tree.
A k-tree is an infinite rooted tree where:
each vertex has exactly k children; each edge has some weight; if we look at the edges that goes from some ... | from sys import stdin, stdout
input = stdin.readline
mp = lambda: map(int, input().split())
it = lambda: int(input())
n, k, d = mp()
mod = 10**9 + 7
dp = [0] * (n + 1)
dp1 = [0] * (n + 1)
dp[0] = 1
dp1[0] = 1
for i in range(1, n + 1):
for j in range(1, k + 1):
if i >= j:
dp[i] += dp[i - j]
... | ASSIGN VAR VAR ASSIGN VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR VAR FUNC_CALL VAR ASSIGN VAR BIN_OP BIN_OP NUMBER NUMBER NUMBER ASSIGN VAR BIN_OP LIST NUMBER BIN_OP VAR NUMBER ASSIGN VAR BIN_OP LIST NUMBER BIN_OP VAR NUMBER ASSIGN VAR NUMBER NUMBER ASSIGN VAR NU... |
Quite recently a creative student Lesha had a lecture on trees. After the lecture Lesha was inspired and came up with the tree of his own which he called a k-tree.
A k-tree is an infinite rooted tree where:
each vertex has exactly k children; each edge has some weight; if we look at the edges that goes from some ... | MOD = 10**9 + 7
I = lambda: list(map(int, input().split()))
[n, k, d] = list(map(int, input().split()))
def F(n, x):
f = [1] + [0] * n
for i in range(1, n + 1):
f[i] = sum(f[max(i - x, 0) : i])
return f[n]
print((F(n, k) - F(n, d - 1)) % MOD) | ASSIGN VAR BIN_OP BIN_OP NUMBER NUMBER NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN LIST VAR VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FUNC_DEF ASSIGN VAR BIN_OP LIST NUMBER BIN_OP LIST NUMBER VAR FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER ASSIGN VAR VAR FUN... |
Quite recently a creative student Lesha had a lecture on trees. After the lecture Lesha was inspired and came up with the tree of his own which he called a k-tree.
A k-tree is an infinite rooted tree where:
each vertex has exactly k children; each edge has some weight; if we look at the edges that goes from some ... | n, k, d = map(int, input().split())
s1 = [0] * 110
s2 = [0] * 110
s1[0], s2[0] = 1, 1
mod = 10**9 + 7
for i in range(1, n + 1):
for j in range(1, k + 1):
if j > i:
break
else:
s1[i] += s1[i - j]
for j in range(1, d):
if j > i:
break
else:
... | ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER NUMBER ASSIGN VAR BIN_OP LIST NUMBER NUMBER ASSIGN VAR NUMBER VAR NUMBER NUMBER NUMBER ASSIGN VAR BIN_OP BIN_OP NUMBER NUMBER NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER IF... |
Quite recently a creative student Lesha had a lecture on trees. After the lecture Lesha was inspired and came up with the tree of his own which he called a k-tree.
A k-tree is an infinite rooted tree where:
each vertex has exactly k children; each edge has some weight; if we look at the edges that goes from some ... | def dp(curr, least, k, total, loc=0):
global d
if curr == total:
return int(least == 0)
if d[curr][int(least == 0)] != -1:
return d[curr][int(least == 0)]
for i in range(1, k + 1):
if curr + i > total:
break
loc += dp(curr + i, 0 if least <= i else least, k, t... | FUNC_DEF NUMBER IF VAR VAR RETURN FUNC_CALL VAR VAR NUMBER IF VAR VAR FUNC_CALL VAR VAR NUMBER NUMBER RETURN VAR VAR FUNC_CALL VAR VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER IF BIN_OP VAR VAR VAR VAR FUNC_CALL VAR BIN_OP VAR VAR VAR VAR NUMBER VAR VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR NUMBER BIN_OP VA... |
Quite recently a creative student Lesha had a lecture on trees. After the lecture Lesha was inspired and came up with the tree of his own which he called a k-tree.
A k-tree is an infinite rooted tree where:
each vertex has exactly k children; each edge has some weight; if we look at the edges that goes from some ... | def read_input():
line = input().strip().split()
n = int(line[0])
k = int(line[1])
d = int(line[2])
print(calculate(n, k, d, {}) % (10**9 + 7))
def calculate(n, k, d, memo):
if (n, d) in memo:
return memo[n, d]
else:
if (n, d) == (0, 0):
return 1
x = 0
... | FUNC_DEF ASSIGN VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR NUMBER EXPR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR VAR VAR DICT BIN_OP BIN_OP NUMBER NUMBER NUMBER FUNC_DEF IF VAR VAR VAR RETURN VAR VAR VAR IF VAR VAR NUMBER NUMBE... |
Quite recently a creative student Lesha had a lecture on trees. After the lecture Lesha was inspired and came up with the tree of his own which he called a k-tree.
A k-tree is an infinite rooted tree where:
each vertex has exactly k children; each edge has some weight; if we look at the edges that goes from some ... | N, K, D = [int(i) for i in input().split()]
M = 100
T = [[0] * (M + 1), [0] * (M + 1)]
for k in range(1, K + 1):
T[k >= D][k] = 1
for n in range(1, M + 1):
for k in range(1, K + 1):
if n + k > M:
continue
T[1][n + k] += T[1][n]
T[k >= D][n + k] += T[0][n]
print(T[1][N] % 1000... | ASSIGN VAR VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR LIST BIN_OP LIST NUMBER BIN_OP VAR NUMBER BIN_OP LIST NUMBER BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER ASSIGN VAR VAR VAR VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR N... |
Quite recently a creative student Lesha had a lecture on trees. After the lecture Lesha was inspired and came up with the tree of his own which he called a k-tree.
A k-tree is an infinite rooted tree where:
each vertex has exactly k children; each edge has some weight; if we look at the edges that goes from some ... | n, k, d = map(int, input().split())
l = max(n, k)
m = min(n, k)
dp = [0] * (2 * l + 1)
dp[l] = 1
dp2 = dp.copy()
for i in range(l + 1, l + n + 1):
for j in range(1, m + 1):
dp[i] += dp[i - j]
for j in range(1, d):
dp2[i] += dp2[i - j]
print((dp[l + n] - dp2[l + n]) % (10**9 + 7)) | ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR ASSIGN VAR BIN_OP LIST NUMBER BIN_OP BIN_OP NUMBER VAR NUMBER ASSIGN VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER BIN_OP BIN_OP VAR VAR NUMBER FOR VAR FUNC_CA... |
Quite recently a creative student Lesha had a lecture on trees. After the lecture Lesha was inspired and came up with the tree of his own which he called a k-tree.
A k-tree is an infinite rooted tree where:
each vertex has exactly k children; each edge has some weight; if we look at the edges that goes from some ... | n, k, d = map(int, input().split())
N = 10**9 + 7
L = max(n, k) + 1
wd = [0] * L
pwd = [0] * L
nd = [1] * L
pnd = [1] * L
for i in range(1, d):
nd[i] = pnd[i - 1] % N
pnd[i] = (pnd[i - 1] + nd[i]) % N
for i in range(d, k + 1):
nd[i] = (pnd[i - 1] - pnd[i - d]) % N
pnd[i] = (pnd[i - 1] + nd[i]) % N
w... | ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP BIN_OP NUMBER NUMBER NUMBER ASSIGN VAR BIN_OP FUNC_CALL VAR VAR VAR NUMBER ASSIGN VAR BIN_OP LIST NUMBER VAR ASSIGN VAR BIN_OP LIST NUMBER VAR ASSIGN VAR BIN_OP LIST NUMBER VAR ASSIGN VAR BIN_OP LIST NUMBER VAR FOR VAR FUNC_CALL VAR NUMBER V... |
Quite recently a creative student Lesha had a lecture on trees. After the lecture Lesha was inspired and came up with the tree of his own which he called a k-tree.
A k-tree is an infinite rooted tree where:
each vertex has exactly k children; each edge has some weight; if we look at the edges that goes from some ... | n, k, d = list(map(int, input().split()))
dict1 = {}
for i in range(1, n + 1):
str1 = str(i) + "_" + "1" + "_" + "1"
dict1[str1] = i
for i in range(1, k + 1):
str1 = "1" + "_" + str(i) + "_" + "1"
dict1[str1] = 1
def solve(n, k, d, z):
str1 = str(n) + "_" + str(k) + "_" + str(d)
if n == 0 or n... | ASSIGN VAR VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR DICT FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER ASSIGN VAR BIN_OP BIN_OP BIN_OP BIN_OP FUNC_CALL VAR VAR STRING STRING STRING STRING ASSIGN VAR VAR VAR FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER ASSIGN VAR BIN_OP BIN_OP BIN_OP... |
Quite recently a creative student Lesha had a lecture on trees. After the lecture Lesha was inspired and came up with the tree of his own which he called a k-tree.
A k-tree is an infinite rooted tree where:
each vertex has exactly k children; each edge has some weight; if we look at the edges that goes from some ... | mod = 10**9 + 7
def find(n, k, d):
dp = [0] * (n + 1)
dp[0] = 1
for i in range(1, n + 1):
j = i - 1
c = 0
s = 0
while j >= 0 and c < k:
s = (s + dp[j]) % mod
j -= 1
c += 1
dp[i] = s
return dp[-1]
n, k, d = map(int, input().s... | ASSIGN VAR BIN_OP BIN_OP NUMBER NUMBER NUMBER FUNC_DEF ASSIGN VAR BIN_OP LIST NUMBER BIN_OP VAR NUMBER ASSIGN VAR NUMBER NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE VAR NUMBER VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR VAR VAR VAR NUMBER VAR... |
Quite recently a creative student Lesha had a lecture on trees. After the lecture Lesha was inspired and came up with the tree of his own which he called a k-tree.
A k-tree is an infinite rooted tree where:
each vertex has exactly k children; each edge has some weight; if we look at the edges that goes from some ... | def dp(n, k, d, f, m):
if n == 0:
if f == True:
return 1
return 0
if n < 0:
return 0
if m[n][f] != -1:
return m[n][f]
res = 0
for i in range(1, k + 1):
if i >= d:
res += dp(n - i, k, d, f | True, m)
else:
res += dp(n... | FUNC_DEF IF VAR NUMBER IF VAR NUMBER RETURN NUMBER RETURN NUMBER IF VAR NUMBER RETURN NUMBER IF VAR VAR VAR NUMBER RETURN VAR VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER IF VAR VAR VAR FUNC_CALL VAR BIN_OP VAR VAR VAR VAR BIN_OP VAR NUMBER VAR VAR FUNC_CALL VAR BIN_OP VAR VAR VAR VAR BIN_OP... |
Quite recently a creative student Lesha had a lecture on trees. After the lecture Lesha was inspired and came up with the tree of his own which he called a k-tree.
A k-tree is an infinite rooted tree where:
each vertex has exactly k children; each edge has some weight; if we look at the edges that goes from some ... | mod = 1000000007
n, k, d = map(int, input().split())
arr = []
for i in range(n + 1):
t = [0, 0]
arr.append(t)
if n < d:
print(0)
else:
arr[1][0] = 1
arr[d][1] = 1
if d == 1:
arr[1][0] = 0
for i in range(2, n + 1):
temp = 0
if i < d:
temp += 1
for j... | ASSIGN VAR NUMBER ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER ASSIGN VAR LIST NUMBER NUMBER EXPR FUNC_CALL VAR VAR IF VAR VAR EXPR FUNC_CALL VAR NUMBER ASSIGN VAR NUMBER NUMBER NUMBER ASSIGN VAR VAR NUMBER NUMBER IF VAR NUMBER ASSIGN VAR NUMBER NU... |
Quite recently a creative student Lesha had a lecture on trees. After the lecture Lesha was inspired and came up with the tree of his own which he called a k-tree.
A k-tree is an infinite rooted tree where:
each vertex has exactly k children; each edge has some weight; if we look at the edges that goes from some ... | n, k, d = list(map(int, input().split()))
f = [0] * (n + k + 1)
f_ = [0] * (n + k + 1)
f_[0] = 1
for i in range(1, n + 1):
for j in range(1, k + 1):
f[i] += f[i - j]
for j in range(d, k + 1):
f[i] += f_[i - j]
for j in range(1, d):
f_[i] += f_[i - j]
print(f[n] % (10**9 + 7)) | ASSIGN VAR VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER BIN_OP BIN_OP VAR VAR NUMBER ASSIGN VAR BIN_OP LIST NUMBER BIN_OP BIN_OP VAR VAR NUMBER ASSIGN VAR NUMBER NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER VAR VAR ... |
Quite recently a creative student Lesha had a lecture on trees. After the lecture Lesha was inspired and came up with the tree of his own which he called a k-tree.
A k-tree is an infinite rooted tree where:
each vertex has exactly k children; each edge has some weight; if we look at the edges that goes from some ... | n, k, d = map(int, input().split())
mod = 1000000007
memo = [([-1] * 100) for i in range(n + 1)]
def dp(nn, s):
sum1 = 0
if nn == 0:
if s == 0:
return 0
else:
return 1
if memo[nn][s] != -1:
return memo[nn][s]
for i in range(1, min(k, nn) + 1):
su... | ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR BIN_OP LIST NUMBER NUMBER VAR FUNC_CALL VAR BIN_OP VAR NUMBER FUNC_DEF ASSIGN VAR NUMBER IF VAR NUMBER IF VAR NUMBER RETURN NUMBER RETURN NUMBER IF VAR VAR VAR NUMBER RETURN VAR VAR VAR FOR VAR FUNC_CALL VAR NUMBER BIN_OP FUNC_CAL... |
Quite recently a creative student Lesha had a lecture on trees. After the lecture Lesha was inspired and came up with the tree of his own which he called a k-tree.
A k-tree is an infinite rooted tree where:
each vertex has exactly k children; each edge has some weight; if we look at the edges that goes from some ... | import sys
import time
def read_line(cast=None):
if cast is not None:
return cast(input().strip())
else:
return input().strip()
def read_list(cast=int):
return list(map(cast, read_line().split()))
INTMAX = 1000000007
res = 0
def dfs(n, k, d, t=False):
global res, INTMAX
if n ... | IMPORT IMPORT FUNC_DEF NONE IF VAR NONE RETURN FUNC_CALL VAR FUNC_CALL FUNC_CALL VAR RETURN FUNC_CALL FUNC_CALL VAR FUNC_DEF VAR RETURN FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER FUNC_DEF NUMBER IF VAR NUMBER RETURN IF VAR NUMBER VAR RETURN IF VAR NUMBER VAR ASSIGN VAR B... |
Quite recently a creative student Lesha had a lecture on trees. After the lecture Lesha was inspired and came up with the tree of his own which he called a k-tree.
A k-tree is an infinite rooted tree where:
each vertex has exactly k children; each edge has some weight; if we look at the edges that goes from some ... | from sys import stdin, stdout
input = stdin.readline
def print(x):
stdout.write(str(x) + "\n")
mod = 10**9 + 7
def solve():
l = list(map(int, input().split()))
n, k, d = l
dp = [([0] * 2) for i in range(n + 1)]
dp[0][0] = 1
dp[0][1] = 0
for i in range(1, n + 1):
for j in range... | ASSIGN VAR VAR FUNC_DEF EXPR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR STRING ASSIGN VAR BIN_OP BIN_OP NUMBER NUMBER NUMBER FUNC_DEF ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR VAR VAR ASSIGN VAR BIN_OP LIST NUMBER NUMBER VAR FUNC_CALL VAR BIN_OP VAR NUMBER ASSIGN VAR NUMBER NUMBER NU... |
Quite recently a creative student Lesha had a lecture on trees. After the lecture Lesha was inspired and came up with the tree of his own which he called a k-tree.
A k-tree is an infinite rooted tree where:
each vertex has exactly k children; each edge has some weight; if we look at the edges that goes from some ... | n, k, d = map(int, input().split())
dp0 = [0] * (n + 1)
dp0[0] = 1
dp1 = [0] * (n + 1)
for i in range(1, n + 1):
j = 1
while k >= j:
if i - j < 0:
break
if j < d:
dp0[i] += dp0[i - j]
dp1[i] += dp1[i - j]
else:
dp1[i] += dp0[i - j]
... | ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER BIN_OP VAR NUMBER ASSIGN VAR NUMBER NUMBER ASSIGN VAR BIN_OP LIST NUMBER BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER ASSIGN VAR NUMBER WHILE VAR VAR IF BIN_OP VAR VAR NUMBER IF VAR VAR VAR VAR VAR BIN_OP VAR ... |
Quite recently a creative student Lesha had a lecture on trees. After the lecture Lesha was inspired and came up with the tree of his own which he called a k-tree.
A k-tree is an infinite rooted tree where:
each vertex has exactly k children; each edge has some weight; if we look at the edges that goes from some ... | n, k, d = map(int, input().split(" "))
a = [0] * (n + 1)
b = [0] * (n + 1)
a[0] = 1
b[0] = 1
m = 1000000007
for i in range(1, n + 1):
a[i] = 0
b[i] = 0
j = 1
while j <= k and i - j >= 0:
a[i] = a[i] + a[i - j]
j = j + 1
j = 1
while j < d and i - j >= 0:
b[i] = b[i] + b[i ... | ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR BIN_OP LIST NUMBER BIN_OP VAR NUMBER ASSIGN VAR BIN_OP LIST NUMBER BIN_OP VAR NUMBER ASSIGN VAR NUMBER NUMBER ASSIGN VAR NUMBER NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER ASSIGN VAR VAR NUMBER ASSIGN VAR VAR NUMB... |
Quite recently a creative student Lesha had a lecture on trees. After the lecture Lesha was inspired and came up with the tree of his own which he called a k-tree.
A k-tree is an infinite rooted tree where:
each vertex has exactly k children; each edge has some weight; if we look at the edges that goes from some ... | n, k, d = map(int, input().split())
MOD = int(1000000000.0 + 7)
dp = [[([0] * (n + 1)) for i in range(n + 1)] for z in range(2)]
dp[0][0][0] = 1
res = 0
for i in range(1, n + 1):
for s in range(1, n + 1):
d0 = 0
d1 = 0
for v in range(1, min(d, s + 1)):
d0 += dp[0][i - 1][s - v]
... | ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR BIN_OP NUMBER NUMBER ASSIGN VAR BIN_OP LIST NUMBER BIN_OP VAR NUMBER VAR FUNC_CALL VAR BIN_OP VAR NUMBER VAR FUNC_CALL VAR NUMBER ASSIGN VAR NUMBER NUMBER NUMBER NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER ... |
Quite recently a creative student Lesha had a lecture on trees. After the lecture Lesha was inspired and came up with the tree of his own which he called a k-tree.
A k-tree is an infinite rooted tree where:
each vertex has exactly k children; each edge has some weight; if we look at the edges that goes from some ... | import sys
sys.setrecursionlimit(1500)
def get_ints():
return list(map(int, sys.stdin.readline().strip().split()))
arr = get_ints()
n = arr[0]
k = arr[1]
d = arr[2]
dicts = {}
ans = 0
def dfs(v, flag):
strs = str(v) + "," + str(flag)
if strs in dicts:
return dicts[strs]
if v > n:
... | IMPORT EXPR FUNC_CALL VAR NUMBER FUNC_DEF RETURN FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR VAR NUMBER ASSIGN VAR VAR NUMBER ASSIGN VAR VAR NUMBER ASSIGN VAR DICT ASSIGN VAR NUMBER FUNC_DEF ASSIGN VAR BIN_OP BIN_OP FUNC_CALL VAR VAR STRING FUNC_CALL VAR VAR IF ... |
Quite recently a creative student Lesha had a lecture on trees. After the lecture Lesha was inspired and came up with the tree of his own which he called a k-tree.
A k-tree is an infinite rooted tree where:
each vertex has exactly k children; each edge has some weight; if we look at the edges that goes from some ... | n, k, d = map(int, input().split())
b = 10**9 + 7
ways = [0] * (n + 1)
ways.insert(0, 0)
j = 1
s = 0
while j <= min(k, n):
ways[j] = 1
j += 1
s += ways[n]
for i in range(2, n + 1):
new_ways = [0] * (n + 1)
for j in range(1, n + 1):
for p in range(1, k + 1):
if j + p <= n:
... | ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP BIN_OP NUMBER NUMBER NUMBER ASSIGN VAR BIN_OP LIST NUMBER BIN_OP VAR NUMBER EXPR FUNC_CALL VAR NUMBER NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE VAR FUNC_CALL VAR VAR VAR ASSIGN VAR VAR NUMBER VAR NUMBER VAR VAR VAR FOR VAR FUNC_CALL V... |
Quite recently a creative student Lesha had a lecture on trees. After the lecture Lesha was inspired and came up with the tree of his own which he called a k-tree.
A k-tree is an infinite rooted tree where:
each vertex has exactly k children; each edge has some weight; if we look at the edges that goes from some ... | n, k, d = map(int, input().split())
kp = [-1] * (n + 1)
def CP(m):
global k
if m == 0:
return 1
if kp[m] != -1:
return kp[m]
c = 0
for t in range(1, min(m, k) + 1):
c += CP(m - t)
c = c % 1000000007
kp[m] = c
return c
kc = [-1] * (n + 1)
def CP2(m):
... | ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER BIN_OP VAR NUMBER FUNC_DEF IF VAR NUMBER RETURN NUMBER IF VAR VAR NUMBER RETURN VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP FUNC_CALL VAR VAR VAR NUMBER VAR FUNC_CALL VAR BIN_OP VAR VAR ASSIGN VAR BIN_OP VAR NUM... |
Quite recently a creative student Lesha had a lecture on trees. After the lecture Lesha was inspired and came up with the tree of his own which he called a k-tree.
A k-tree is an infinite rooted tree where:
each vertex has exactly k children; each edge has some weight; if we look at the edges that goes from some ... | N, K, D = map(int, input().split())
mod = 10**9 + 7
dpK = [(0) for i in range(N + 1)]
dpK[0] = 1
for i in range(1, N + 1):
for j in range(1, K + 1):
if i >= j:
dpK[i] += dpK[i - j]
dpK[i] %= mod
dp = [(0) for i in range(N + 1)]
dp[0] = 1
for i in range(1, N + 1):
for j in range(1, D):
... | ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP BIN_OP NUMBER NUMBER NUMBER ASSIGN VAR NUMBER VAR FUNC_CALL VAR BIN_OP VAR NUMBER ASSIGN VAR NUMBER NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER IF VAR VAR VAR VAR VAR BIN_OP VAR VAR VA... |
Quite recently a creative student Lesha had a lecture on trees. After the lecture Lesha was inspired and came up with the tree of his own which he called a k-tree.
A k-tree is an infinite rooted tree where:
each vertex has exactly k children; each edge has some weight; if we look at the edges that goes from some ... | n, k, d = map(int, input().split())
mat = [1]
sat = [1]
for i in range(1, n + 1):
mat.append(sum(mat[max(i - d + 1, 0) :]))
sat.append(sum(sat[max(i - k, 0) :]))
print((sat[-1] - mat[-1]) % 1000000007) | ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST NUMBER ASSIGN VAR LIST NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER EXPR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL VAR BIN_OP BIN_OP VAR VAR NUMBER NUMBER EXPR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL VAR BIN_OP VAR VAR NUMBER EXPR F... |
Quite recently a creative student Lesha had a lecture on trees. After the lecture Lesha was inspired and came up with the tree of his own which he called a k-tree.
A k-tree is an infinite rooted tree where:
each vertex has exactly k children; each edge has some weight; if we look at the edges that goes from some ... | s = input()
s1 = s.split()
tot = int(s1[0])
n = int(s1[1])
d = int(s1[2])
l = [int(i) for i in range(1, n + 1)]
final = 0
temp = tot
dp = [(0) for i in range(temp + 1)]
dp[0] = 1
for i in range(1, temp + 1):
sum1 = 0
for j in range(1, n + 1):
if i - j >= 0:
sum1 = sum1 + dp[i - j]
dp[i] ... | ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR VAR ASSIGN VAR NUMBER VAR FUNC_CALL VAR BIN_OP VAR NUMBER ASS... |
Quite recently a creative student Lesha had a lecture on trees. After the lecture Lesha was inspired and came up with the tree of his own which he called a k-tree.
A k-tree is an infinite rooted tree where:
each vertex has exactly k children; each edge has some weight; if we look at the edges that goes from some ... | n, k, d = map(int, input().split())
dp = [[(0) for i in range(2)] for i in range(101)]
dp[0][0] = 1
dp[0][1] = 1
for i in range(1, 101):
dp[i][0] = sum(dp[j][0] for j in range(i - min(i, d), i))
if min(i, d) == d:
dp[i][0] = dp[i][0] - dp[i - d][0]
dp[i][1] = sum(dp[j][1] for j in range(i - min(i, k... | ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER VAR FUNC_CALL VAR NUMBER VAR FUNC_CALL VAR NUMBER ASSIGN VAR NUMBER NUMBER NUMBER ASSIGN VAR NUMBER NUMBER NUMBER FOR VAR FUNC_CALL VAR NUMBER NUMBER ASSIGN VAR VAR NUMBER FUNC_CALL VAR VAR VAR NUMBER VAR FUNC_CALL VAR BIN_OP VAR FUNC_CALL V... |
Quite recently a creative student Lesha had a lecture on trees. After the lecture Lesha was inspired and came up with the tree of his own which he called a k-tree.
A k-tree is an infinite rooted tree where:
each vertex has exactly k children; each edge has some weight; if we look at the edges that goes from some ... | n, k, d = map(int, input().split())
dp = [0] * (n + 1)
mod = 10**9 + 7
dp[0] = 1
for i in range(1, n + 1):
for j in range(1, k + 1):
if i >= j:
dp[i] += dp[i - j]
dp[i] %= mod
if d == 1:
print(dp[n])
else:
dp1 = [0] * (n + 1)
dp1[0] = 1
for i in range(1, n + 1):
for j... | ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER BIN_OP VAR NUMBER ASSIGN VAR BIN_OP BIN_OP NUMBER NUMBER NUMBER ASSIGN VAR NUMBER NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER IF VAR VAR VAR VAR VAR BIN_OP VAR VAR VAR VAR ... |
Quite recently a creative student Lesha had a lecture on trees. After the lecture Lesha was inspired and came up with the tree of his own which he called a k-tree.
A k-tree is an infinite rooted tree where:
each vertex has exactly k children; each edge has some weight; if we look at the edges that goes from some ... | mod = 10**9 + 7
def solve(n, k):
dp = [0] * 101
if k <= 0:
return 0
for i in range(1, k + 1):
dp[i] = 1
for i in range(1, n + 1):
for j in range(1, min(k + 1, i)):
dp[i] = dp[i] + dp[i - j]
dp[i] = dp[i] % mod
return dp[n]
mod = 10**9 + 7
a = list(... | ASSIGN VAR BIN_OP BIN_OP NUMBER NUMBER NUMBER FUNC_DEF ASSIGN VAR BIN_OP LIST NUMBER NUMBER IF VAR NUMBER RETURN NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER ASSIGN VAR VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER FUNC_CALL VAR BIN_OP VAR NUMBER VAR ASSIGN VAR VAR BIN_... |
Quite recently a creative student Lesha had a lecture on trees. After the lecture Lesha was inspired and came up with the tree of his own which he called a k-tree.
A k-tree is an infinite rooted tree where:
each vertex has exactly k children; each edge has some weight; if we look at the edges that goes from some ... | input_ = list(map(int, input().split()))
n, k, d = input_[0], input_[1], input_[2]
dp = [["None" for i in range(d + 1)] for j in range(n + 1)]
for j in range(d + 1):
dp[0][j] = 0
for i in range(n + 1):
if j > i:
dp[i][j] = 0
if dp[1][j] == "None":
dp[1][j] = 1
for i in range(... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR VAR VAR NUMBER VAR NUMBER VAR NUMBER ASSIGN VAR STRING VAR FUNC_CALL VAR BIN_OP VAR NUMBER VAR FUNC_CALL VAR BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER ASSIGN VAR NUMBER VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER IF... |
Quite recently a creative student Lesha had a lecture on trees. After the lecture Lesha was inspired and came up with the tree of his own which he called a k-tree.
A k-tree is an infinite rooted tree where:
each vertex has exactly k children; each edge has some weight; if we look at the edges that goes from some ... | n, k, d = map(int, input().split())
dp = [[(0) for _ in range(2)] for _ in range(n + 1)]
dp[0][0] = 1
for i in range(n + 1):
for j in range(i - 1, -1, -1):
if i - j > k:
break
if i - j < d:
dp[i][0] += dp[j][0]
dp[i][1] += dp[j][1]
if i - j >= d and i - j ... | ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER VAR FUNC_CALL VAR NUMBER VAR FUNC_CALL VAR BIN_OP VAR NUMBER ASSIGN VAR NUMBER NUMBER NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER NUMBER NUMBER IF BIN_OP VAR VAR VAR IF BIN_OP VAR VAR VAR VAR VAR NU... |
Quite recently a creative student Lesha had a lecture on trees. After the lecture Lesha was inspired and came up with the tree of his own which he called a k-tree.
A k-tree is an infinite rooted tree where:
each vertex has exactly k children; each edge has some weight; if we look at the edges that goes from some ... | import sys
f = sys.stdin
n, k, d = map(int, f.readline().strip().split())
Nd = [[1] * (n + 1), [1] * (n + 1)]
Nd[1][0] = 0
Nd[1][1] = 0
for i in range(2, n + 1):
N = 0
for j in range(1, k + 1):
if i >= j:
N += Nd[0][i - j]
Nd[0][i] = N
N = 0
for j in range(1, k + 1):
if ... | IMPORT ASSIGN VAR VAR ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST BIN_OP LIST NUMBER BIN_OP VAR NUMBER BIN_OP LIST NUMBER BIN_OP VAR NUMBER ASSIGN VAR NUMBER NUMBER NUMBER ASSIGN VAR NUMBER NUMBER NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER ASSIGN VAR NUMBER FOR VAR ... |
Quite recently a creative student Lesha had a lecture on trees. After the lecture Lesha was inspired and came up with the tree of his own which he called a k-tree.
A k-tree is an infinite rooted tree where:
each vertex has exactly k children; each edge has some weight; if we look at the edges that goes from some ... | n, k, d = map(int, input().split())
mod = 10**9 + 7
add = [0] * 105
sub = [0] * 105
add[0] = sub[0] = 1
for i in range(n + 1):
for p in range(min(n - i, k)):
add[p + i + 1] = (add[p + i + 1] + add[i]) % mod
for q in range(min(n - i, d - 1)):
sub[q + i + 1] = (sub[q + i + 1] + sub[i]) % mod
print... | ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP BIN_OP NUMBER NUMBER NUMBER ASSIGN VAR BIN_OP LIST NUMBER NUMBER ASSIGN VAR BIN_OP LIST NUMBER NUMBER ASSIGN VAR NUMBER VAR NUMBER NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR BIN_OP VAR VAR VAR ASSIGN V... |
Quite recently a creative student Lesha had a lecture on trees. After the lecture Lesha was inspired and came up with the tree of his own which he called a k-tree.
A k-tree is an infinite rooted tree where:
each vertex has exactly k children; each edge has some weight; if we look at the edges that goes from some ... | MOD = 10**9 + 7
n, k, d = [int(x) for x in input().split()]
include = [(0) for i in range(n + 1)]
exclude = [(0) for i in range(n + 1)]
for i in range(n + 1):
if i <= k:
include[i] = 1
if i < d:
exclude[i] = 1
include[0] = exclude[0] = 0
for i in range(1, n + 1):
for j in range(1, k ... | ASSIGN VAR BIN_OP BIN_OP NUMBER NUMBER NUMBER ASSIGN VAR VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER VAR FUNC_CALL VAR BIN_OP VAR NUMBER ASSIGN VAR NUMBER VAR FUNC_CALL VAR BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER IF VAR VAR ASSIGN VAR VAR NUMBER IF VAR VAR ASSIGN VAR VAR NU... |
Quite recently a creative student Lesha had a lecture on trees. After the lecture Lesha was inspired and came up with the tree of his own which he called a k-tree.
A k-tree is an infinite rooted tree where:
each vertex has exactly k children; each edge has some weight; if we look at the edges that goes from some ... | MODULO = int(1000000000.0) + 7
def findnumways(n, d_state, k, d, num_ways):
if n < 0:
return 0
if n == 0 and not d_state:
return 0
if n == 0 and d_state:
return 1
if (n, d_state) in num_ways:
return num_ways[n, d_state]
cnt = 0
for i in range(1, k + 1):
... | ASSIGN VAR BIN_OP FUNC_CALL VAR NUMBER NUMBER FUNC_DEF IF VAR NUMBER RETURN NUMBER IF VAR NUMBER VAR RETURN NUMBER IF VAR NUMBER VAR RETURN NUMBER IF VAR VAR VAR RETURN VAR VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER IF VAR VAR VAR BIN_OP FUNC_CALL VAR BIN_OP VAR VAR NUMBER VAR VAR VAR VAR ... |
Quite recently a creative student Lesha had a lecture on trees. After the lecture Lesha was inspired and came up with the tree of his own which he called a k-tree.
A k-tree is an infinite rooted tree where:
each vertex has exactly k children; each edge has some weight; if we look at the edges that goes from some ... | MOD = 1000000007
dp = [[(-1) for i in range(2)] for j in range(101)]
def k_tree(n, k, d, least_d_selected):
if least_d_selected:
selected_index = 1
else:
selected_index = 0
if n < 0:
return 0
if n == 0 and least_d_selected:
return 1
if n == 0 and not least_d_selecte... | ASSIGN VAR NUMBER ASSIGN VAR NUMBER VAR FUNC_CALL VAR NUMBER VAR FUNC_CALL VAR NUMBER FUNC_DEF IF VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER IF VAR NUMBER RETURN NUMBER IF VAR NUMBER VAR RETURN NUMBER IF VAR NUMBER VAR RETURN NUMBER ASSIGN VAR NUMBER IF VAR VAR VAR NUMBER RETURN VAR VAR VAR FOR VAR FUNC_CALL VAR VAR IF VA... |
Quite recently a creative student Lesha had a lecture on trees. After the lecture Lesha was inspired and came up with the tree of his own which he called a k-tree.
A k-tree is an infinite rooted tree where:
each vertex has exactly k children; each edge has some weight; if we look at the edges that goes from some ... | n, k, d = [int(x) for x in input().split()]
dp = [(1) for i in range(n + 1)]
for i in range(1, n + 1):
dp[i] = sum([dp[i - j] for j in range(1, k + 1) if i - j >= 0])
dp_d1 = [(1) for i in range(n + 1)]
for i in range(1, n + 1):
dp_d1[i] = sum([dp_d1[i - j] for j in range(1, min(k + 1, d)) if i - j >= 0])
print... | ASSIGN VAR VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER VAR FUNC_CALL VAR BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER ASSIGN VAR VAR FUNC_CALL VAR VAR BIN_OP VAR VAR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER BIN_OP VAR VAR NUMBER ASSIGN VAR NUMBER VAR FUNC_CALL VAR BIN_O... |
Quite recently a creative student Lesha had a lecture on trees. After the lecture Lesha was inspired and came up with the tree of his own which he called a k-tree.
A k-tree is an infinite rooted tree where:
each vertex has exactly k children; each edge has some weight; if we look at the edges that goes from some ... | n, k, d = map(int, input().split())
dp = [[(0) for j in range(2)] for i in range(105)]
dp[0][1] = 1
for i in range(1, n + 1):
for j in range(1, min(i, k) + 1):
dp[i][0] = (dp[i][0] + dp[i - j][j >= d]) % 1000000007
dp[i][1] = (dp[i][1] + dp[i - j][1]) % 1000000007
print(dp[n][0]) | ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER VAR FUNC_CALL VAR NUMBER VAR FUNC_CALL VAR NUMBER ASSIGN VAR NUMBER NUMBER NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP FUNC_CALL VAR VAR VAR NUMBER ASSIGN VAR VAR NUMBER BIN_OP BIN_OP VAR VAR NUM... |
Quite recently a creative student Lesha had a lecture on trees. After the lecture Lesha was inspired and came up with the tree of his own which he called a k-tree.
A k-tree is an infinite rooted tree where:
each vertex has exactly k children; each edge has some weight; if we look at the edges that goes from some ... | mod = 1000000007
n, k, d = map(int, input().split())
if n < d:
print(0)
else:
dp = [0] * (n + 1)
dp[0] = 1
dpp = [0] * (n + 1)
dpp[0] = 1
for i in range(1, n + 1):
for j in range(1, k + 1):
if i >= j:
dp[i] = (dp[i - j] + dp[i]) % mod
if i >= j and... | ASSIGN VAR NUMBER ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR VAR EXPR FUNC_CALL VAR NUMBER ASSIGN VAR BIN_OP LIST NUMBER BIN_OP VAR NUMBER ASSIGN VAR NUMBER NUMBER ASSIGN VAR BIN_OP LIST NUMBER BIN_OP VAR NUMBER ASSIGN VAR NUMBER NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER FOR VAR FUN... |
Quite recently a creative student Lesha had a lecture on trees. After the lecture Lesha was inspired and came up with the tree of his own which he called a k-tree.
A k-tree is an infinite rooted tree where:
each vertex has exactly k children; each edge has some weight; if we look at the edges that goes from some ... | dp = [0] * 101
dpx = [0] * 101
n, k, d = input().split()
n = int(n)
k = int(k)
d = int(d)
dp[0] = 1
dpx[0] = 1
for i in range(1, n + 1):
for j in range(1, min(i, k) + 1):
dp[i] = dp[i] + dp[i - j]
for i in range(1, n + 1):
for j in range(1, min(i, d - 1) + 1):
dpx[i] = dpx[i] + dpx[i - j]
print(... | ASSIGN VAR BIN_OP LIST NUMBER NUMBER ASSIGN VAR BIN_OP LIST NUMBER NUMBER ASSIGN VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER NUMBER ASSIGN VAR NUMBER NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER FOR VAR FUNC_CALL V... |
Quite recently a creative student Lesha had a lecture on trees. After the lecture Lesha was inspired and came up with the tree of his own which he called a k-tree.
A k-tree is an infinite rooted tree where:
each vertex has exactly k children; each edge has some weight; if we look at the edges that goes from some ... | dp = []
def f(n, k, d):
global dp
if n < 0:
return 0
if n == 0 and d == 0:
dp[n][k][d] = 1
return 1
if dp[n][k][d] != -1:
return dp[n][k][d]
cont = 0
for i in range(1, k + 1):
cont += f(n - i, k, 0 if i >= d else d)
dp[n][k][d] = cont
return cont... | ASSIGN VAR LIST FUNC_DEF IF VAR NUMBER RETURN NUMBER IF VAR NUMBER VAR NUMBER ASSIGN VAR VAR VAR VAR NUMBER RETURN NUMBER IF VAR VAR VAR VAR NUMBER RETURN VAR VAR VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER VAR FUNC_CALL VAR BIN_OP VAR VAR VAR VAR VAR NUMBER VAR ASSIGN VAR VAR VAR VAR VAR R... |
Quite recently a creative student Lesha had a lecture on trees. After the lecture Lesha was inspired and came up with the tree of his own which he called a k-tree.
A k-tree is an infinite rooted tree where:
each vertex has exactly k children; each edge has some weight; if we look at the edges that goes from some ... | n, k, d = map(int, input().split())
dp = {}
vis = []
def F(curr, poss):
if curr < 0:
return 0
if curr == 0 and poss == 1:
return 1
if (curr, poss) in vis:
return dp[curr, poss]
i = 1
vis.append((curr, poss))
dp[curr, poss] = 0
while i < d:
dp[curr, poss] += ... | ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR DICT ASSIGN VAR LIST FUNC_DEF IF VAR NUMBER RETURN NUMBER IF VAR NUMBER VAR NUMBER RETURN NUMBER IF VAR VAR VAR RETURN VAR VAR VAR ASSIGN VAR NUMBER EXPR FUNC_CALL VAR VAR VAR ASSIGN VAR VAR VAR NUMBER WHILE VAR VAR VAR VAR VAR FUNC_CALL VAR BIN_OP... |
Quite recently a creative student Lesha had a lecture on trees. After the lecture Lesha was inspired and came up with the tree of his own which he called a k-tree.
A k-tree is an infinite rooted tree where:
each vertex has exactly k children; each edge has some weight; if we look at the edges that goes from some ... | import sys
sys.setrecursionlimit(100000)
n, k, d = [int(x) for x in sys.stdin.readline().strip().split()]
memo = {}
m = 10**9 + 7
def dp(n, k, d):
key = str(n) + str(d)
if n == 0:
return 1
if n < 0:
return 0
if key in memo:
return memo[key]
s = 0
for i in range(1, k + ... | IMPORT EXPR FUNC_CALL VAR NUMBER ASSIGN VAR VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR ASSIGN VAR DICT ASSIGN VAR BIN_OP BIN_OP NUMBER NUMBER NUMBER FUNC_DEF ASSIGN VAR BIN_OP FUNC_CALL VAR VAR FUNC_CALL VAR VAR IF VAR NUMBER RETURN NUMBER IF VAR NUMBER RETURN NUMBER IF VAR VAR RETURN VAR VAR ASSIG... |
Quite recently a creative student Lesha had a lecture on trees. After the lecture Lesha was inspired and came up with the tree of his own which he called a k-tree.
A k-tree is an infinite rooted tree where:
each vertex has exactly k children; each edge has some weight; if we look at the edges that goes from some ... | def sol(n, k, d):
if n <= d:
if n == d:
return 1
else:
return 0
if (n, k, d) not in dic:
ans = 0
for i in range(1, k + 1):
if i >= d:
ans += sol(n - i, k, 0)
else:
ans += sol(n - i, k, d)
dic[... | FUNC_DEF IF VAR VAR IF VAR VAR RETURN NUMBER RETURN NUMBER IF VAR VAR VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER IF VAR VAR VAR FUNC_CALL VAR BIN_OP VAR VAR VAR NUMBER VAR FUNC_CALL VAR BIN_OP VAR VAR VAR VAR ASSIGN VAR VAR VAR VAR BIN_OP VAR NUMBER RETURN VAR VAR VAR VAR ASSIGN VAR FUNC_C... |
Quite recently a creative student Lesha had a lecture on trees. After the lecture Lesha was inspired and came up with the tree of his own which he called a k-tree.
A k-tree is an infinite rooted tree where:
each vertex has exactly k children; each edge has some weight; if we look at the edges that goes from some ... | n, k, d = map(int, input().split())
dp = [[-1, -1] for j in range(101)]
m = 10**9 + 7
def ans(n, t):
global d, m, k
if dp[n][t] >= 0:
return dp[n][t]
if n == d and t == 0:
return 1
if n < d and t == 0:
return 0
if n == 0:
return 1
c = 0
for i in range(1, d):... | ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST NUMBER NUMBER VAR FUNC_CALL VAR NUMBER ASSIGN VAR BIN_OP BIN_OP NUMBER NUMBER NUMBER FUNC_DEF IF VAR VAR VAR NUMBER RETURN VAR VAR VAR IF VAR VAR VAR NUMBER RETURN NUMBER IF VAR VAR VAR NUMBER RETURN NUMBER IF VAR NUMBER RETURN NUMBER ASSIGN V... |
Quite recently a creative student Lesha had a lecture on trees. After the lecture Lesha was inspired and came up with the tree of his own which he called a k-tree.
A k-tree is an infinite rooted tree where:
each vertex has exactly k children; each edge has some weight; if we look at the edges that goes from some ... | def main():
mod = 10**9 + 7
n, k, d = map(int, input().split())
dp = [0] * (n + 1)
for i in range(1, n + 1):
for j in range(1, k + 1):
if i - j >= 0:
dp[i] += dp[i - j]
dp[i] %= mod
if i <= k:
dp[i] += 1
dp1 = [0] * (n + 1)
for ... | FUNC_DEF ASSIGN VAR BIN_OP BIN_OP NUMBER NUMBER NUMBER ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER IF BIN_OP VAR VAR NUMBER VAR VAR VAR BIN_OP VAR VAR VAR VAR VA... |
Quite recently a creative student Lesha had a lecture on trees. After the lecture Lesha was inspired and came up with the tree of his own which he called a k-tree.
A k-tree is an infinite rooted tree where:
each vertex has exactly k children; each edge has some weight; if we look at the edges that goes from some ... | def prog():
n, k, d = map(int, input().split())
mod = 10**9 + 7
ways = [(0) for i in range(n + 1)]
for i in range(1, min(k + 1, n + 1)):
ways[i] = 1
for i in range(1, n + 1):
for j in range(max(1, i - k), i):
ways[i] += ways[j]
ways_less_d = [(0) for i in range(n + 1)... | FUNC_DEF ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP BIN_OP NUMBER NUMBER NUMBER ASSIGN VAR NUMBER VAR FUNC_CALL VAR BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER FUNC_CALL VAR BIN_OP VAR NUMBER BIN_OP VAR NUMBER ASSIGN VAR VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER FO... |
Quite recently a creative student Lesha had a lecture on trees. After the lecture Lesha was inspired and came up with the tree of his own which he called a k-tree.
A k-tree is an infinite rooted tree where:
each vertex has exactly k children; each edge has some weight; if we look at the edges that goes from some ... | n, k, d = map(int, input().split())
M = 10**9 + 7
dp = [[(0) for i in range(2)] for j in range(n + 1)]
dp[0][0] = 1
dp[0][1] = 0
for i in range(1, n + 1):
for j in range(1, k + 1):
if i - j >= 0:
dp[i][1] = (dp[i][1] + dp[i - j][1]) % M
if j >= d:
dp[i][1] = (dp[i][1]... | ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP BIN_OP NUMBER NUMBER NUMBER ASSIGN VAR NUMBER VAR FUNC_CALL VAR NUMBER VAR FUNC_CALL VAR BIN_OP VAR NUMBER ASSIGN VAR NUMBER NUMBER NUMBER ASSIGN VAR NUMBER NUMBER NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR N... |
Quite recently a creative student Lesha had a lecture on trees. After the lecture Lesha was inspired and came up with the tree of his own which he called a k-tree.
A k-tree is an infinite rooted tree where:
each vertex has exactly k children; each edge has some weight; if we look at the edges that goes from some ... | n, k, d = map(int, input().split())
mod = 10**9 + 7
dp = [([0] * (k + 1)) for i in range(n + 1)]
dp[0][0] = 1
for su in range(n + 1):
for mi in range(k + 1):
for i in range(1, k + 1):
if su + i <= n:
dp[su + i][max(i, mi)] += dp[su][mi] % mod
print(int(sum(dp[n][d:]) % mod)) | ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP BIN_OP NUMBER NUMBER NUMBER ASSIGN VAR BIN_OP LIST NUMBER BIN_OP VAR NUMBER VAR FUNC_CALL VAR BIN_OP VAR NUMBER ASSIGN VAR NUMBER NUMBER NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER FOR VAR FUNC_CALL... |
Quite recently a creative student Lesha had a lecture on trees. After the lecture Lesha was inspired and came up with the tree of his own which he called a k-tree.
A k-tree is an infinite rooted tree where:
each vertex has exactly k children; each edge has some weight; if we look at the edges that goes from some ... | MOD = 10**9 + 7
n, k, d = [int(k) for k in input().split()]
ways1 = [0] * (n + 1)
ways1[0] = 1
ways1[1] = 1
for i in range(2, n + 1):
for j in range(max(0, i - k), i):
ways1[i] += ways1[j]
ways1[i] %= MOD
ways2 = [0] * (n + 1)
ways2[0] = 1
ways2[1] = 1
if d == 1:
ways2[0] = 0
ways2[1] = 0
for i ... | ASSIGN VAR BIN_OP BIN_OP NUMBER NUMBER NUMBER ASSIGN VAR VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER BIN_OP VAR NUMBER ASSIGN VAR NUMBER NUMBER ASSIGN VAR NUMBER NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR NUMBER BIN_OP VAR VAR VAR VA... |
Quite recently a creative student Lesha had a lecture on trees. After the lecture Lesha was inspired and came up with the tree of his own which he called a k-tree.
A k-tree is an infinite rooted tree where:
each vertex has exactly k children; each edge has some weight; if we look at the edges that goes from some ... | n, k, d = map(int, input().split())
a = [1]
b = [0]
for i in range(1, n + 1):
a.append(sum(a[max(i - d + 1, 0) :]))
b.append(sum(a[max(i - k, 0) : max(i - d + 1, 0)]) + sum(b[max(i - k, 0) :]))
print(b[n] % (10**9 + 7)) | ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST NUMBER ASSIGN VAR LIST NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER EXPR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL VAR BIN_OP BIN_OP VAR VAR NUMBER NUMBER EXPR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR FUNC_CALL VAR BIN_OP VAR VAR NUMBER... |
Quite recently a creative student Lesha had a lecture on trees. After the lecture Lesha was inspired and came up with the tree of his own which he called a k-tree.
A k-tree is an infinite rooted tree where:
each vertex has exactly k children; each edge has some weight; if we look at the edges that goes from some ... | n, k, d = input().split()
n = int(n)
k = int(k)
d = int(d)
dp = [0] * (n + 1)
s = [0] * (n + 1)
dp[0] = 1
s[0] = 1
if n < d:
print(0)
else:
for i in range(1, n + 1):
for j in range(1, k + 1):
if j <= i:
dp[i] = dp[i] + dp[i - j]
for j in range(1, d):
if j ... | ASSIGN VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP LIST NUMBER BIN_OP VAR NUMBER ASSIGN VAR BIN_OP LIST NUMBER BIN_OP VAR NUMBER ASSIGN VAR NUMBER NUMBER ASSIGN VAR NUMBER NUMBER IF VAR VAR EXPR FUNC_CALL VAR NUMBER FOR VAR... |
Quite recently a creative student Lesha had a lecture on trees. After the lecture Lesha was inspired and came up with the tree of his own which he called a k-tree.
A k-tree is an infinite rooted tree where:
each vertex has exactly k children; each edge has some weight; if we look at the edges that goes from some ... | inp = input().split()
n = int(inp[0])
k = int(inp[1])
d = int(inp[2])
dp = []
for i in range(0, 110):
dp.append(0)
dp[0] = 1
for i in range(0, n):
for j in range(1, k + 1):
if i + j > n:
break
else:
dp[i + j] = dp[i + j] + dp[i]
dp2 = []
for i in range(0, 110):
dp2.ap... | ASSIGN VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR LIST FOR VAR FUNC_CALL VAR NUMBER NUMBER EXPR FUNC_CALL VAR NUMBER ASSIGN VAR NUMBER NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR N... |
Quite recently a creative student Lesha had a lecture on trees. After the lecture Lesha was inspired and came up with the tree of his own which he called a k-tree.
A k-tree is an infinite rooted tree where:
each vertex has exactly k children; each edge has some weight; if we look at the edges that goes from some ... | from sys import stderr, stdin
def readInts():
return map(int, stdin.readline().strip().split())
def print_err(*args, **kwargs):
print(*args, file=stderr, **kwargs)
def naive_kt(k, d, n):
if n < 0:
return 0
if n < d:
return 0
if n == 0:
return 1
s = 0
for i in ra... | FUNC_DEF RETURN FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR FUNC_DEF EXPR FUNC_CALL VAR VAR VAR VAR FUNC_DEF IF VAR NUMBER RETURN NUMBER IF VAR VAR RETURN NUMBER IF VAR NUMBER RETURN NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER ASSIGN VAR NUMBER IF VAR VAR ASSIGN VAR NUMBER ASSIGN VAR... |
Quite recently a creative student Lesha had a lecture on trees. After the lecture Lesha was inspired and came up with the tree of his own which he called a k-tree.
A k-tree is an infinite rooted tree where:
each vertex has exactly k children; each edge has some weight; if we look at the edges that goes from some ... | n, k, d = map(int, input().split())
dp = [None, (0, 1)] if d > 1 else [None, (1, 1)]
for i in range(2, n + 1):
if i < d:
s, u = 0, 1
elif i <= k:
s = u = 1
else:
s = u = 0
for j in range(1, min(i, k + 1)):
if j < d:
s += dp[i - j][0]
else:
... | ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR NUMBER LIST NONE NUMBER NUMBER LIST NONE NUMBER NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER IF VAR VAR ASSIGN VAR VAR NUMBER NUMBER IF VAR VAR ASSIGN VAR VAR NUMBER ASSIGN VAR VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER FUNC_CALL VAR VAR ... |
Quite recently a creative student Lesha had a lecture on trees. After the lecture Lesha was inspired and came up with the tree of his own which he called a k-tree.
A k-tree is an infinite rooted tree where:
each vertex has exactly k children; each edge has some weight; if we look at the edges that goes from some ... | import sys
input = sys.stdin.readline
def inInt():
return int(input())
def inStr():
return input().strip("\n")
def inIList():
return list(map(int, input().split()))
def inSList():
return input().split()
def bsearch(nums, target):
N = len(nums or [])
l = 0
r = N - 1
while l <= ... | IMPORT ASSIGN VAR VAR FUNC_DEF RETURN FUNC_CALL VAR FUNC_CALL VAR FUNC_DEF RETURN FUNC_CALL FUNC_CALL VAR STRING FUNC_DEF RETURN FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FUNC_DEF RETURN FUNC_CALL FUNC_CALL VAR FUNC_DEF ASSIGN VAR FUNC_CALL VAR VAR LIST ASSIGN VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER WHILE... |
Quite recently a creative student Lesha had a lecture on trees. After the lecture Lesha was inspired and came up with the tree of his own which he called a k-tree.
A k-tree is an infinite rooted tree where:
each vertex has exactly k children; each edge has some weight; if we look at the edges that goes from some ... | mod = 10**9 + 7
path = [([-1] * 2) for _ in range(101)]
def count(i, state):
if path[i][state] != -1:
return path[i][state]
if i == 0:
return state
result = 0
for j in range(1, k + 1):
if i >= j:
result = (result + count(i - j, [1, state][j < d])) % mod
path[i][... | ASSIGN VAR BIN_OP BIN_OP NUMBER NUMBER NUMBER ASSIGN VAR BIN_OP LIST NUMBER NUMBER VAR FUNC_CALL VAR NUMBER FUNC_DEF IF VAR VAR VAR NUMBER RETURN VAR VAR VAR IF VAR NUMBER RETURN VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER IF VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR FUNC_CALL VAR BIN_OP VAR VAR LIS... |
Quite recently a creative student Lesha had a lecture on trees. After the lecture Lesha was inspired and came up with the tree of his own which he called a k-tree.
A k-tree is an infinite rooted tree where:
each vertex has exactly k children; each edge has some weight; if we look at the edges that goes from some ... | n, k, d = map(int, input().split())
l = [1] + [0] * n
m = [1] + [0] * n
for i in range(0, n + 1):
for j in range(1, d):
if i + j <= n:
l[i + j] += l[i]
for i in range(0, n + 1):
for j in range(1, k + 1):
if i + j <= n:
m[i + j] += m[i]
print((m[n] - l[n]) % (10**9 + 7)) | ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER BIN_OP LIST NUMBER VAR ASSIGN VAR BIN_OP LIST NUMBER BIN_OP LIST NUMBER VAR FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR IF BIN_OP VAR VAR VAR VAR BIN_OP VAR VAR VAR VAR FOR VAR FUNC_CALL VAR NU... |
Quite recently a creative student Lesha had a lecture on trees. After the lecture Lesha was inspired and came up with the tree of his own which he called a k-tree.
A k-tree is an infinite rooted tree where:
each vertex has exactly k children; each edge has some weight; if we look at the edges that goes from some ... | mod = int(1000000000.0 + 7)
n, k, d = map(int, input().split())
dp = [(0) for i in range(n + k + 1)]
dp[0] = 1
for i in range(n + 1):
for j in range(1, k + 1):
dp[i + j] += dp[i]
dp2 = [(0) for i in range(n + k + 1)]
dp2[0] = 1
for i in range(n + 1):
for j in range(1, d):
dp2[i + j] += dp2[i]
pr... | ASSIGN VAR FUNC_CALL VAR BIN_OP NUMBER NUMBER ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER VAR FUNC_CALL VAR BIN_OP BIN_OP VAR VAR NUMBER ASSIGN VAR NUMBER NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER VAR BIN_OP VAR VAR VAR VAR ASSIGN VA... |
Quite recently a creative student Lesha had a lecture on trees. After the lecture Lesha was inspired and came up with the tree of his own which he called a k-tree.
A k-tree is an infinite rooted tree where:
each vertex has exactly k children; each edge has some weight; if we look at the edges that goes from some ... | inp = input().split()
n = int(inp[0])
k = int(inp[1])
d = int(inp[2])
if n < d:
print(0)
else:
D = [[(0) for i in range(n + 1)], [(0) for j in range(n + 1)]]
D[0][0] = 0
D[1][0] = 0
for j in range(n):
if j + 1 <= k and d <= j + 1:
D[1][j + 1] = 1
elif j + 1 <= k and d > j... | ASSIGN VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR NUMBER IF VAR VAR EXPR FUNC_CALL VAR NUMBER ASSIGN VAR LIST NUMBER VAR FUNC_CALL VAR BIN_OP VAR NUMBER NUMBER VAR FUNC_CALL VAR BIN_OP VAR NUMBER ASSIGN VAR NUMBER NUMBER NUMBER ASSIGN... |
Quite recently a creative student Lesha had a lecture on trees. After the lecture Lesha was inspired and came up with the tree of his own which he called a k-tree.
A k-tree is an infinite rooted tree where:
each vertex has exactly k children; each edge has some weight; if we look at the edges that goes from some ... | n, k, d = map(int, input().split())
dp = [[(0) for j in range(2)] for i in range(101)]
dp[0][1] = 1
for i in range(1, n + 1):
for j in range(1, min(i, k) + 1):
if j >= d:
dp[i][0] = (dp[i][0] + dp[i - j][1]) % int(1000000000.0 + 7)
else:
dp[i][0] = (dp[i][0] + dp[i - j][0]) %... | ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER VAR FUNC_CALL VAR NUMBER VAR FUNC_CALL VAR NUMBER ASSIGN VAR NUMBER NUMBER NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP FUNC_CALL VAR VAR VAR NUMBER IF VAR VAR ASSIGN VAR VAR NUMBER BIN_OP BIN_OP ... |
Quite recently a creative student Lesha had a lecture on trees. After the lecture Lesha was inspired and came up with the tree of his own which he called a k-tree.
A k-tree is an infinite rooted tree where:
each vertex has exactly k children; each edge has some weight; if we look at the edges that goes from some ... | def calculateWays(summ, maxNumber):
p = [0] * (summ + 1)
dp = []
for i in range(summ + 1):
dp.append(p.copy())
for i in range(summ):
for j in range(summ):
x = i + 1
y = j + 1
if x <= y:
prevWays = 0
for ii in range(y - 1... | FUNC_DEF ASSIGN VAR BIN_OP LIST NUMBER BIN_OP VAR NUMBER ASSIGN VAR LIST FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER IF VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NU... |
Quite recently a creative student Lesha had a lecture on trees. After the lecture Lesha was inspired and came up with the tree of his own which he called a k-tree.
A k-tree is an infinite rooted tree where:
each vertex has exactly k children; each edge has some weight; if we look at the edges that goes from some ... | mod = 10**9 + 7
n, k, d = map(int, input().strip().split())
notD = [(0) for i in range(n + 1)]
notD[0] = 1
withD = [(0) for i in range(n + 1)]
withD[0] = 1
for i in range(n + 1):
for j in range(1, d):
if i >= j:
notD[i] += notD[i - j]
for i in range(n + 1):
for j in range(1, k + 1):
... | ASSIGN VAR BIN_OP BIN_OP NUMBER NUMBER NUMBER ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER VAR FUNC_CALL VAR BIN_OP VAR NUMBER ASSIGN VAR NUMBER NUMBER ASSIGN VAR NUMBER VAR FUNC_CALL VAR BIN_OP VAR NUMBER ASSIGN VAR NUMBER NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER FOR V... |
Quite recently a creative student Lesha had a lecture on trees. After the lecture Lesha was inspired and came up with the tree of his own which he called a k-tree.
A k-tree is an infinite rooted tree where:
each vertex has exactly k children; each edge has some weight; if we look at the edges that goes from some ... | import sys
input = sys.stdin.readline
read_tuple = lambda _type: map(_type, input().split(" "))
def solve():
n, k, d = read_tuple(int)
edges = [i for i in range(1, k + 1)]
cnt_normal = [(0) for _ in range(n + 1)]
cnt_d = [(0) for _ in range(n + 1)]
for i in range(1, n + 1):
for edge in ed... | IMPORT ASSIGN VAR VAR ASSIGN VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR STRING FUNC_DEF ASSIGN VAR VAR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER ASSIGN VAR NUMBER VAR FUNC_CALL VAR BIN_OP VAR NUMBER ASSIGN VAR NUMBER VAR FUNC_CALL VAR BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR NUMB... |
Quite recently a creative student Lesha had a lecture on trees. After the lecture Lesha was inspired and came up with the tree of his own which he called a k-tree.
A k-tree is an infinite rooted tree where:
each vertex has exactly k children; each edge has some weight; if we look at the edges that goes from some ... | mod = 10**9 + 7
def ktree(l, a, dp, k, d):
if l < 0:
return 0
if l == 0 and a == 0:
return 0
if l == 0 and a == 1:
return 1
if dp[l][a] != -1:
return dp[l][a]
sum = 0
for i in range(1, k + 1):
if i >= d:
sum += ktree(l - i, 1, dp, k, d)
... | ASSIGN VAR BIN_OP BIN_OP NUMBER NUMBER NUMBER FUNC_DEF IF VAR NUMBER RETURN NUMBER IF VAR NUMBER VAR NUMBER RETURN NUMBER IF VAR NUMBER VAR NUMBER RETURN NUMBER IF VAR VAR VAR NUMBER RETURN VAR VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER IF VAR VAR VAR FUNC_CALL VAR BIN_OP VAR VAR NUMBER VA... |
Quite recently a creative student Lesha had a lecture on trees. After the lecture Lesha was inspired and came up with the tree of his own which he called a k-tree.
A k-tree is an infinite rooted tree where:
each vertex has exactly k children; each edge has some weight; if we look at the edges that goes from some ... | import sys
mod = 1000000007
get_arr = lambda: list(map(int, input().split()))
get_int = lambda: int(input())
get_ints = lambda: map(int, input().split())
get_str = lambda: input()
get_strs = lambda: input().split()
def fn(n, k, d, flag, cache, mod):
if n == 0 and flag:
return 1
if n == 0 and not flag... | IMPORT ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL FUNC_CALL VAR FUNC_DEF IF VAR NUMBER VAR RETURN NUMBER IF VAR NUMBER VAR RETURN NUMBER IF ... |
Quite recently a creative student Lesha had a lecture on trees. After the lecture Lesha was inspired and came up with the tree of his own which he called a k-tree.
A k-tree is an infinite rooted tree where:
each vertex has exactly k children; each edge has some weight; if we look at the edges that goes from some ... | def getInts():
return [int(s) for s in input().split()]
def getInt():
return int(input())
def getStrs():
return [s for s in input().split()]
def getStr():
return input()
def listStr():
return list(input())
M = 10**9 + 7
def solve():
N, K, D = getInts()
dp = [[(0) for j in range(2... | FUNC_DEF RETURN FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR FUNC_DEF RETURN FUNC_CALL VAR FUNC_CALL VAR FUNC_DEF RETURN VAR VAR FUNC_CALL FUNC_CALL VAR FUNC_DEF RETURN FUNC_CALL VAR FUNC_DEF RETURN FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR BIN_OP BIN_OP NUMBER NUMBER NUMBER FUNC_DEF ASSIGN VAR VAR VAR FUNC_CALL VAR ASSI... |
Quite recently a creative student Lesha had a lecture on trees. After the lecture Lesha was inspired and came up with the tree of his own which he called a k-tree.
A k-tree is an infinite rooted tree where:
each vertex has exactly k children; each edge has some weight; if we look at the edges that goes from some ... | def w(N, K):
a = [0] * (N + 1)
a[0] = 1
for i in range(1, min(N, K) + 1):
a[i] = sum(a[0:i])
if N > K:
for x in range(K + 1, N + 1):
a[x] = sum(a[x - K : x])
return a[-1]
def sol():
n, k, g = map(int, input().split(" "))
result = (w(n, k) - w(n, g - 1)) % (10**9... | FUNC_DEF ASSIGN VAR BIN_OP LIST NUMBER BIN_OP VAR NUMBER ASSIGN VAR NUMBER NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP FUNC_CALL VAR VAR VAR NUMBER ASSIGN VAR VAR FUNC_CALL VAR VAR NUMBER VAR IF VAR VAR FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER BIN_OP VAR NUMBER ASSIGN VAR VAR FUNC_CALL VAR VAR BIN_OP VAR VAR VAR RETURN V... |
Quite recently a creative student Lesha had a lecture on trees. After the lecture Lesha was inspired and came up with the tree of his own which he called a k-tree.
A k-tree is an infinite rooted tree where:
each vertex has exactly k children; each edge has some weight; if we look at the edges that goes from some ... | def sums(n, k, d, dic):
count = 0
limited_count = 0
for i in range(1, k + 1):
if n - i == 0:
count += 1
if n >= d:
limited_count += 1
elif n - i < 0:
pass
else:
count += dic[n - i][0]
if i >= d:
... | FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER IF BIN_OP VAR VAR NUMBER VAR NUMBER IF VAR VAR VAR NUMBER IF BIN_OP VAR VAR NUMBER VAR VAR BIN_OP VAR VAR NUMBER IF VAR VAR VAR VAR BIN_OP VAR VAR NUMBER VAR VAR BIN_OP VAR VAR NUMBER RETURN BIN_OP VAR BIN_OP BIN_OP NUMBER NUMBE... |
Quite recently a creative student Lesha had a lecture on trees. After the lecture Lesha was inspired and came up with the tree of his own which he called a k-tree.
A k-tree is an infinite rooted tree where:
each vertex has exactly k children; each edge has some weight; if we look at the edges that goes from some ... | def f(k, n, d, b, l):
if n < 0 or b == 0 and n < d:
return 0
elif l[n][b] > 0:
return l[n][b]
else:
cnt = 0
for i in range(1, k + 1):
if i < d:
cnt += f(k, n - i, d, b, l)
else:
cnt += f(k, n - i, d, 1, l)
l[n][b... | FUNC_DEF IF VAR NUMBER VAR NUMBER VAR VAR RETURN NUMBER IF VAR VAR VAR NUMBER RETURN VAR VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER IF VAR VAR VAR FUNC_CALL VAR VAR BIN_OP VAR VAR VAR VAR VAR VAR FUNC_CALL VAR VAR BIN_OP VAR VAR VAR NUMBER VAR ASSIGN VAR VAR VAR VAR RETURN VAR ASSIGN VAR V... |
Quite recently a creative student Lesha had a lecture on trees. After the lecture Lesha was inspired and came up with the tree of his own which he called a k-tree.
A k-tree is an infinite rooted tree where:
each vertex has exactly k children; each edge has some weight; if we look at the edges that goes from some ... | n, k, d = [int(x) for x in input().split()]
klist = [(0) for i in range(101)]
dminusonelist = [(0) for i in range(101)]
twopower = 1
for i in range(1, k + 1):
klist[i] = twopower
twopower = twopower * 2 % 1000000007
twopower = 1
for i in range(1, d):
dminusonelist[i] = twopower
twopower = twopower * 2 %... | ASSIGN VAR VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER VAR FUNC_CALL VAR NUMBER ASSIGN VAR NUMBER VAR FUNC_CALL VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER ASSIGN VAR VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR NUMBER NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NU... |
Quite recently a creative student Lesha had a lecture on trees. After the lecture Lesha was inspired and came up with the tree of his own which he called a k-tree.
A k-tree is an infinite rooted tree where:
each vertex has exactly k children; each edge has some weight; if we look at the edges that goes from some ... | m = 1000000007
def mod_add(a, b):
return (a % m + b % m) % m
def solve(n, k, d, flag, dp):
if n < 0:
return 0
if n == 0:
if flag == False:
return 1
else:
return 0
if (n, flag) in dp:
return dp[n, flag]
temp = 0
f = flag
for i in ran... | ASSIGN VAR NUMBER FUNC_DEF RETURN BIN_OP BIN_OP BIN_OP VAR VAR BIN_OP VAR VAR VAR FUNC_DEF IF VAR NUMBER RETURN NUMBER IF VAR NUMBER IF VAR NUMBER RETURN NUMBER RETURN NUMBER IF VAR VAR VAR RETURN VAR VAR VAR ASSIGN VAR NUMBER ASSIGN VAR VAR FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER IF VAR VAR ASSIGN VAR NUMBER AS... |
Quite recently a creative student Lesha had a lecture on trees. After the lecture Lesha was inspired and came up with the tree of his own which he called a k-tree.
A k-tree is an infinite rooted tree where:
each vertex has exactly k children; each edge has some weight; if we look at the edges that goes from some ... | def F(n, k):
if k < 2:
return k
b = [0] * (k - 1) + [1]
for i in range(n):
b.append(sum(b[-k:]) % (10**9 + 7))
return b[-1]
n, k, d = list(map(int, input().split()))
ans = F(n, k) - F(n, d - 1)
if ans < 0:
ans += 10**9 + 7
print(ans) | FUNC_DEF IF VAR NUMBER RETURN VAR ASSIGN VAR BIN_OP BIN_OP LIST NUMBER BIN_OP VAR NUMBER LIST NUMBER FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR VAR BIN_OP BIN_OP NUMBER NUMBER NUMBER RETURN VAR NUMBER ASSIGN VAR VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP... |
Quite recently a creative student Lesha had a lecture on trees. After the lecture Lesha was inspired and came up with the tree of his own which he called a k-tree.
A k-tree is an infinite rooted tree where:
each vertex has exactly k children; each edge has some weight; if we look at the edges that goes from some ... | def main():
n, k, d = map(int, input().split())
n += 1
k += 1
l1le, l1ge = [0] * n, [0] * n
l1le[0] = 1
res = 0
for _ in range(n - d + 1):
l0le, l0ge, l1le, l1ge = l1le, l1ge, [0] * n, [0] * n
for i, x in enumerate(l0le):
if x:
x %= 1000000007
... | FUNC_DEF ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR VAR NUMBER VAR NUMBER ASSIGN VAR VAR BIN_OP LIST NUMBER VAR BIN_OP LIST NUMBER VAR ASSIGN VAR NUMBER NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP BIN_OP VAR VAR NUMBER ASSIGN VAR VAR VAR VAR VAR VAR BIN_OP LIST NUMBER VAR BIN_OP LIST NUMBER ... |
Quite recently a creative student Lesha had a lecture on trees. After the lecture Lesha was inspired and came up with the tree of his own which he called a k-tree.
A k-tree is an infinite rooted tree where:
each vertex has exactly k children; each edge has some weight; if we look at the edges that goes from some ... | MOD = 10**9 + 7
def calculate(n, max_k):
if max_k == 0:
return 0
dp = [0] * (n + 1)
dp[1] = 1
for i in range(2, n + 1):
m = min(i - 1, max_k)
if i <= max_k:
dp[i] += 1
for j in range(1, m + 1):
dp[i] += dp[i - j]
dp[i] = dp[i] % MOD
... | ASSIGN VAR BIN_OP BIN_OP NUMBER NUMBER NUMBER FUNC_DEF IF VAR NUMBER RETURN NUMBER ASSIGN VAR BIN_OP LIST NUMBER BIN_OP VAR NUMBER ASSIGN VAR NUMBER NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER ASSIGN VAR FUNC_CALL VAR BIN_OP VAR NUMBER VAR IF VAR VAR VAR VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMB... |
Quite recently a creative student Lesha had a lecture on trees. After the lecture Lesha was inspired and came up with the tree of his own which he called a k-tree.
A k-tree is an infinite rooted tree where:
each vertex has exactly k children; each edge has some weight; if we look at the edges that goes from some ... | n, k, d = input().strip().split()
n = int(n)
k = int(k)
d = int(d)
dp = [(0) for i in range(102)]
dp[0] = 1
p = [(0) for i in range(102)]
p[0] = 1
for i in range(1, n + 1):
for j in range(1, k + 1):
if i - j < 0:
break
dp[i] = (dp[i] + dp[i - j]) % 1000000007
for j in range(1, d):
... | ASSIGN VAR VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER VAR FUNC_CALL VAR NUMBER ASSIGN VAR NUMBER NUMBER ASSIGN VAR NUMBER VAR FUNC_CALL VAR NUMBER ASSIGN VAR NUMBER NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMB... |
Quite recently a creative student Lesha had a lecture on trees. After the lecture Lesha was inspired and came up with the tree of his own which he called a k-tree.
A k-tree is an infinite rooted tree where:
each vertex has exactly k children; each edge has some weight; if we look at the edges that goes from some ... | n, k, d = list(map(int, input().split()))
def paths_with_weight(n, k, d):
if n == 0:
return 1 if d == 0 else 0
if n < 0:
return 0
return sum(
[paths_with_weight(n - i, k, d if i < d else 0) for i in range(1, k + 1)]
)
def dp_paths_with_weight(n, k, d, modulo=0):
P = [[(0)... | ASSIGN VAR VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FUNC_DEF IF VAR NUMBER RETURN VAR NUMBER NUMBER NUMBER IF VAR NUMBER RETURN NUMBER RETURN FUNC_CALL VAR FUNC_CALL VAR BIN_OP VAR VAR VAR VAR VAR VAR NUMBER VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER FUNC_DEF NUMBER ASSIGN VAR NUMBER VAR FUNC_CAL... |
Quite recently a creative student Lesha had a lecture on trees. After the lecture Lesha was inspired and came up with the tree of his own which he called a k-tree.
A k-tree is an infinite rooted tree where:
each vertex has exactly k children; each edge has some weight; if we look at the edges that goes from some ... | b = [False] * 101
x = [0] * 101
def count(w, k1):
if w == 0:
return 1
elif w < 0:
return 0
ans = 0
for i in range(1, k1 + 1):
if w - i < 0:
break
if b[w - i]:
ans = ans + x[w - i]
else:
x[w - i] = count(w - i, k1)
... | ASSIGN VAR BIN_OP LIST NUMBER NUMBER ASSIGN VAR BIN_OP LIST NUMBER NUMBER FUNC_DEF IF VAR NUMBER RETURN NUMBER IF VAR NUMBER RETURN NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER IF BIN_OP VAR VAR NUMBER IF VAR BIN_OP VAR VAR ASSIGN VAR BIN_OP VAR VAR BIN_OP VAR VAR ASSIGN VAR BIN_OP VAR VAR FU... |
Quite recently a creative student Lesha had a lecture on trees. After the lecture Lesha was inspired and came up with the tree of his own which he called a k-tree.
A k-tree is an infinite rooted tree where:
each vertex has exactly k children; each edge has some weight; if we look at the edges that goes from some ... | n, k, d = map(int, input().split())
dp1 = [0] * (n + 1)
dp2 = [0] * (n + 1)
dp1[0] = 1
for i in range(1, n + 1):
for j in range(1, min(n, k) + 1):
dp2[i] += dp2[i - j]
if j < d:
dp1[i] += dp1[i - j]
else:
dp2[i] += dp1[i - j]
print(dp2[n] % 1000000007) | ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER BIN_OP VAR NUMBER ASSIGN VAR BIN_OP LIST NUMBER BIN_OP VAR NUMBER ASSIGN VAR NUMBER NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP FUNC_CALL VAR VAR VAR NUMBER VAR VAR VAR BIN_OP VAR VAR... |
Quite recently a creative student Lesha had a lecture on trees. After the lecture Lesha was inspired and came up with the tree of his own which he called a k-tree.
A k-tree is an infinite rooted tree where:
each vertex has exactly k children; each edge has some weight; if we look at the edges that goes from some ... | dp1 = [0] * 101
dp2 = [0] * 101
n, k, d = map(int, input().split())
for i in range(1, k + 1):
dp1[i] = 1
if i < d:
dp2[i] = 1
dp1[0] = 0
dp2[0] = 0
m = 10**9 + 7
for i in range(1, n + 1):
for j in range(1, k + 1):
if i > j:
dp1[i] = (dp1[i] + dp1[i - j]) % m
if j < d:... | ASSIGN VAR BIN_OP LIST NUMBER NUMBER ASSIGN VAR BIN_OP LIST NUMBER NUMBER ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER ASSIGN VAR VAR NUMBER IF VAR VAR ASSIGN VAR VAR NUMBER ASSIGN VAR NUMBER NUMBER ASSIGN VAR NUMBER NUMBER ASSIGN VAR BIN_OP BIN_OP NUMBER N... |
Quite recently a creative student Lesha had a lecture on trees. After the lecture Lesha was inspired and came up with the tree of his own which he called a k-tree.
A k-tree is an infinite rooted tree where:
each vertex has exactly k children; each edge has some weight; if we look at the edges that goes from some ... | def count(n, item):
new, x, summa, i = [], 1, 0, 0
for i in range(1, min(n + 1, item + 1)):
new.append(x)
summa += x
x *= 2
x = x % 1000000007
summa = summa % 1000000007
z = 0
for j in range(i + 1, n + 1):
new.append(summa)
summa += new[-1] - new[z... | FUNC_DEF ASSIGN VAR VAR VAR VAR LIST NUMBER NUMBER NUMBER FOR VAR FUNC_CALL VAR NUMBER FUNC_CALL VAR BIN_OP VAR NUMBER BIN_OP VAR NUMBER EXPR FUNC_CALL VAR VAR VAR VAR VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER BIN_OP VAR NUMBER EXPR FU... |
Quite recently a creative student Lesha had a lecture on trees. After the lecture Lesha was inspired and came up with the tree of his own which he called a k-tree.
A k-tree is an infinite rooted tree where:
each vertex has exactly k children; each edge has some weight; if we look at the edges that goes from some ... | temp = list(map(int, input().split()))
n, k, d = temp[0], temp[1], temp[2]
mod = 1000000007
dp = [[0, 0] for _ in range(n + 1)]
dp[0][0] = 1
dp[0][1] = 0
for i in range(1, n + 1):
for j in range(1, min(i, k) + 1):
if j < d:
dp[i][0] += dp[i - j][0] % mod
dp[i][1] += dp[i - j][1] % mo... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR VAR VAR NUMBER VAR NUMBER VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR LIST NUMBER NUMBER VAR FUNC_CALL VAR BIN_OP VAR NUMBER ASSIGN VAR NUMBER NUMBER NUMBER ASSIGN VAR NUMBER NUMBER NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER FOR VA... |
Quite recently a creative student Lesha had a lecture on trees. After the lecture Lesha was inspired and came up with the tree of his own which he called a k-tree.
A k-tree is an infinite rooted tree where:
each vertex has exactly k children; each edge has some weight; if we look at the edges that goes from some ... | from sys import stdin, stdout
n, k, d = stdin.readline().split()
n = int(n)
k = int(k)
d = int(d)
mod = 1000000007
wd = [(0) for i in range(n + 1)]
wo = [(0) for i in range(n + 1)]
wd[0] = 1
wo[0] = 1
for i in range(1, n + 1):
for j in range(1, k + 1):
if i - j >= 0:
wd[i] += wd[i - j]
... | ASSIGN VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER VAR FUNC_CALL VAR BIN_OP VAR NUMBER ASSIGN VAR NUMBER VAR FUNC_CALL VAR BIN_OP VAR NUMBER ASSIGN VAR NUMBER NUMBER ASSIGN VAR NUMBER NUMBER FOR VAR FUNC_C... |
Quite recently a creative student Lesha had a lecture on trees. After the lecture Lesha was inspired and came up with the tree of his own which he called a k-tree.
A k-tree is an infinite rooted tree where:
each vertex has exactly k children; each edge has some weight; if we look at the edges that goes from some ... | dpall = []
dpd = []
MOD = 1000000007
n, k, d = map(int, input("").split(" "))
for i in range(105):
dpall.append(None)
dpd.append(None)
def solveD(u):
if u == 0:
return 1
if dpd[u] != None:
return dpd[u]
ans = 0
for i in range(1, min(min(d - 1, k), u) + 1):
ans += solveD... | ASSIGN VAR LIST ASSIGN VAR LIST ASSIGN VAR NUMBER ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR STRING STRING FOR VAR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR NONE EXPR FUNC_CALL VAR NONE FUNC_DEF IF VAR NUMBER RETURN NUMBER IF VAR VAR NONE RETURN VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN... |
Quite recently a creative student Lesha had a lecture on trees. After the lecture Lesha was inspired and came up with the tree of his own which he called a k-tree.
A k-tree is an infinite rooted tree where:
each vertex has exactly k children; each edge has some weight; if we look at the edges that goes from some ... | def run():
n, k, d = (int(x) for x in input().split(" "))
value = recurse(n, k, d, 0, dict()) % 1000000007
print(value)
def recurse(n, k, d, r, memo):
if n == 0:
if d == -1:
return 1
else:
return 0
elif n < 0:
return 0
key = "level={}, n={}, d={}... | FUNC_DEF ASSIGN VAR VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR BIN_OP FUNC_CALL VAR VAR VAR VAR NUMBER FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR VAR FUNC_DEF IF VAR NUMBER IF VAR NUMBER RETURN NUMBER RETURN NUMBER IF VAR NUMBER RETURN NUMBER ASSIGN VAR FUNC_CALL STRING VAR VAR VAR IF VAR FUNC... |
Quite recently a creative student Lesha had a lecture on trees. After the lecture Lesha was inspired and came up with the tree of his own which he called a k-tree.
A k-tree is an infinite rooted tree where:
each vertex has exactly k children; each edge has some weight; if we look at the edges that goes from some ... | mem = [[-1, -1] for x in range(0, 103)]
n, k, d = list(map(int, input().split()))
def dp(remain, has_d):
if remain == 0:
return has_d
if remain < 0:
return 0
if mem[remain][has_d] != -1:
return mem[remain][has_d]
mem[remain][has_d] = 0
for i in range(1, min(remain, k) + 1):... | ASSIGN VAR LIST NUMBER NUMBER VAR FUNC_CALL VAR NUMBER NUMBER ASSIGN VAR VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FUNC_DEF IF VAR NUMBER RETURN VAR IF VAR NUMBER RETURN NUMBER IF VAR VAR VAR NUMBER RETURN VAR VAR VAR ASSIGN VAR VAR VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP FUNC_CALL VAR VAR ... |
Quite recently a creative student Lesha had a lecture on trees. After the lecture Lesha was inspired and came up with the tree of his own which he called a k-tree.
A k-tree is an infinite rooted tree where:
each vertex has exactly k children; each edge has some weight; if we look at the edges that goes from some ... | from sys import stdin
mod = 1000000007
def sol(n, k):
arr = [(0) for i in range(n + 1)]
acum = [(0) for i in range(n + 1)]
for i in range(1, min(k, n) + 1):
arr[i] = 1
acum[i] = 1
for qq in range(n):
arr1 = [(0) for i in range(n + 1)]
for i in range(1, n + 1):
... | ASSIGN VAR NUMBER FUNC_DEF ASSIGN VAR NUMBER VAR FUNC_CALL VAR BIN_OP VAR NUMBER ASSIGN VAR NUMBER VAR FUNC_CALL VAR BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP FUNC_CALL VAR VAR VAR NUMBER ASSIGN VAR VAR NUMBER ASSIGN VAR VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER VAR FUNC_CALL VAR BIN_OP VAR NUM... |
Quite recently a creative student Lesha had a lecture on trees. After the lecture Lesha was inspired and came up with the tree of his own which he called a k-tree.
A k-tree is an infinite rooted tree where:
each vertex has exactly k children; each edge has some weight; if we look at the edges that goes from some ... | def numWays(n, k):
if k == 0:
return 0
s = [1] * (n + 1)
for i in range(2, min(k + 1, n + 1)):
s[i] = s[i - 1] << 1
for i in range(k + 1, n + 1):
s[i] = (s[i - 1] << 1) - s[i - k - 1]
return s[n]
def solve():
n, k, d = map(int, input().split())
mod = 1000000007
... | FUNC_DEF IF VAR NUMBER RETURN NUMBER ASSIGN VAR BIN_OP LIST NUMBER BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER FUNC_CALL VAR BIN_OP VAR NUMBER BIN_OP VAR NUMBER ASSIGN VAR VAR BIN_OP VAR BIN_OP VAR NUMBER NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER BIN_OP VAR NUMBER ASSIGN VAR VAR BIN_OP BIN_OP VAR BIN_OP VAR NUM... |
Quite recently a creative student Lesha had a lecture on trees. After the lecture Lesha was inspired and came up with the tree of his own which he called a k-tree.
A k-tree is an infinite rooted tree where:
each vertex has exactly k children; each edge has some weight; if we look at the edges that goes from some ... | n, k, d = map(int, input().split())
dp = [[(0) for i in range(2)] for j in range(n + 10)]
dp[0][0] = 1
MOD = int(1000000000.0) + 7
for i in range(1, n + 1):
for j in range(1, min(d - 1, n) + 1):
dp[i][0] += dp[i - j][0] % MOD
for j in range(1, min(d - 1, n) + 1):
dp[i][1] += dp[i - j][1] % MOD
... | ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER VAR FUNC_CALL VAR NUMBER VAR FUNC_CALL VAR BIN_OP VAR NUMBER ASSIGN VAR NUMBER NUMBER NUMBER ASSIGN VAR BIN_OP FUNC_CALL VAR NUMBER NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP FUNC_CALL VAR BIN_O... |
Quite recently a creative student Lesha had a lecture on trees. After the lecture Lesha was inspired and came up with the tree of his own which he called a k-tree.
A k-tree is an infinite rooted tree where:
each vertex has exactly k children; each edge has some weight; if we look at the edges that goes from some ... | n, k, d = list(map(int, input().split()))
MOD = 10**9 + 7
dp = {}
def rec(remaining, flag=False):
if remaining < 0:
return 0
if remaining == 0 and flag == True:
return 1
if (remaining, flag) in dp:
return dp[remaining, flag]
ans = 0
for i in range(1, k + 1):
if i <=... | ASSIGN VAR VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP BIN_OP NUMBER NUMBER NUMBER ASSIGN VAR DICT FUNC_DEF NUMBER IF VAR NUMBER RETURN NUMBER IF VAR NUMBER VAR NUMBER RETURN NUMBER IF VAR VAR VAR RETURN VAR VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER I... |
Quite recently a creative student Lesha had a lecture on trees. After the lecture Lesha was inspired and came up with the tree of his own which he called a k-tree.
A k-tree is an infinite rooted tree where:
each vertex has exactly k children; each edge has some weight; if we look at the edges that goes from some ... | def k_tree(n, k, d):
def _k_tree(n, k):
if k <= 0 or n <= 0:
return 0
cache = [1] * n
for i in range(1, n):
sum_num = 0
for j in range(max(0, i - k), i):
sum_num += cache[j]
if i < k:
sum_num += 1
ca... | FUNC_DEF FUNC_DEF IF VAR NUMBER VAR NUMBER RETURN NUMBER ASSIGN VAR BIN_OP LIST NUMBER VAR FOR VAR FUNC_CALL VAR NUMBER VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR NUMBER BIN_OP VAR VAR VAR VAR VAR VAR IF VAR VAR VAR NUMBER ASSIGN VAR VAR VAR RETURN VAR NUMBER RETURN BIN_OP FUNC_CALL VAR VAR VAR FUNC_CALL... |
Quite recently a creative student Lesha had a lecture on trees. After the lecture Lesha was inspired and came up with the tree of his own which he called a k-tree.
A k-tree is an infinite rooted tree where:
each vertex has exactly k children; each edge has some weight; if we look at the edges that goes from some ... | n, k, d = input().split()
n, k, d = int(n), int(k), int(d)
mod = 10**9 + 7
dp = [1]
for i in range(1, n + 1):
if i == 1:
dp.append(1)
else:
dp.append(0)
for j in range(1, min(k, i) + 1):
dp[-1] += dp[i - j]
dp[-1] %= mod
DP = [0]
for i in range(1, n + 1):
if i < d... | ASSIGN VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL VAR VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP BIN_OP NUMBER NUMBER NUMBER ASSIGN VAR LIST NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER IF VAR NUMBER EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR NUMBER FOR VAR FUNC_CALL VAR ... |
Quite recently a creative student Lesha had a lecture on trees. After the lecture Lesha was inspired and came up with the tree of his own which he called a k-tree.
A k-tree is an infinite rooted tree where:
each vertex has exactly k children; each edge has some weight; if we look at the edges that goes from some ... | def solve(s):
n, k, d = list(map(int, s.split()))
return int((dp(n, k) - dp(n, d - 1)) % 1000000007)
def dp(n, k):
l = [(2**i) for i in range(k)]
while len(l) < n:
l.append(sum(l[-k:]))
return l[n - 1]
s = input()
print(solve(s)) | FUNC_DEF ASSIGN VAR VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL VAR RETURN FUNC_CALL VAR BIN_OP BIN_OP FUNC_CALL VAR VAR VAR FUNC_CALL VAR VAR BIN_OP VAR NUMBER NUMBER FUNC_DEF ASSIGN VAR BIN_OP NUMBER VAR VAR FUNC_CALL VAR VAR WHILE FUNC_CALL VAR VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR VAR VAR RETURN VAR BIN_OP... |
Quite recently a creative student Lesha had a lecture on trees. After the lecture Lesha was inspired and came up with the tree of his own which he called a k-tree.
A k-tree is an infinite rooted tree where:
each vertex has exactly k children; each edge has some weight; if we look at the edges that goes from some ... | memo = {}
tg, k, d = map(int, input().split())
def rec(n):
if n in memo:
return memo[n]
ans = [0, 0]
for b in range(1, min(k, n) + 1):
if b == n:
ans[b >= d] += 1
continue
r = rec(n - b)
ans[1] += r[1]
ans[b >= d] += r[0]
memo[n] = ans
... | ASSIGN VAR DICT ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FUNC_DEF IF VAR VAR RETURN VAR VAR ASSIGN VAR LIST NUMBER NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP FUNC_CALL VAR VAR VAR NUMBER IF VAR VAR VAR VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR BIN_OP VAR VAR VAR NUMBER VAR NUMBER VAR VAR VAR VAR NUMBE... |
Quite recently a creative student Lesha had a lecture on trees. After the lecture Lesha was inspired and came up with the tree of his own which he called a k-tree.
A k-tree is an infinite rooted tree where:
each vertex has exactly k children; each edge has some weight; if we look at the edges that goes from some ... | mod = int(1000000000.0 + 7)
n, k, d = map(int, input().split())
dp = [[(0) for _ in " " * 2] for _ in range(n + 1)]
dp[0][0] = 1
dp[0][1] = 0
for i in range(1, n + 1):
for j in range(1, k + 1):
if i < j:
break
dp[i][j >= d] += dp[i - j][0] % mod
dp[i][1] += dp[i - j][1] % mod
pri... | ASSIGN VAR FUNC_CALL VAR BIN_OP NUMBER NUMBER ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER VAR BIN_OP STRING NUMBER VAR FUNC_CALL VAR BIN_OP VAR NUMBER ASSIGN VAR NUMBER NUMBER NUMBER ASSIGN VAR NUMBER NUMBER NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR N... |
Quite recently a creative student Lesha had a lecture on trees. After the lecture Lesha was inspired and came up with the tree of his own which he called a k-tree.
A k-tree is an infinite rooted tree where:
each vertex has exactly k children; each edge has some weight; if we look at the edges that goes from some ... | mod = 10**9 + 7
def countWays(arr, m, N, d):
count = [(0) for i in range(N + 1)]
count[0] = 1
for i in range(1, N + 1):
for j in range(m):
if i >= arr[j] and arr[j] < d:
count[i] += count[i - arr[j]]
count[i] %= mod
return count[N]
def countWays1(arr, ... | ASSIGN VAR BIN_OP BIN_OP NUMBER NUMBER NUMBER FUNC_DEF ASSIGN VAR NUMBER VAR FUNC_CALL VAR BIN_OP VAR NUMBER ASSIGN VAR NUMBER NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF VAR VAR VAR VAR VAR VAR VAR VAR VAR BIN_OP VAR VAR VAR VAR VAR VAR RETURN VAR VAR FUNC_DEF ASSIGN VAR NUMBER V... |
Quite recently a creative student Lesha had a lecture on trees. After the lecture Lesha was inspired and came up with the tree of his own which he called a k-tree.
A k-tree is an infinite rooted tree where:
each vertex has exactly k children; each edge has some weight; if we look at the edges that goes from some ... | a = input()
list_a = list(map(int, a.split()))
n = list_a[0]
k = list_a[1]
d = list_a[2]
solutions = []
for numbers in range(n + 1):
solutions.append(-1)
def dp(n, k, solutions):
if n == 1:
solutions[1] = 1
return 1
if solutions[n] != -1:
return solutions[n]
else:
answe... | ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL VAR ASSIGN VAR VAR NUMBER ASSIGN VAR VAR NUMBER ASSIGN VAR VAR NUMBER ASSIGN VAR LIST FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR NUMBER FUNC_DEF IF VAR NUMBER ASSIGN VAR NUMBER NUMBER RETURN NUMBER IF VAR VAR NUMBER RETURN VAR... |
Quite recently a creative student Lesha had a lecture on trees. After the lecture Lesha was inspired and came up with the tree of his own which he called a k-tree.
A k-tree is an infinite rooted tree where:
each vertex has exactly k children; each edge has some weight; if we look at the edges that goes from some ... | import sys
inf = float("inf")
mod, MOD = 1000000007, 998244353
def get_array():
return list(map(int, sys.stdin.readline().strip().split()))
def get_ints():
return map(int, sys.stdin.readline().strip().split())
def input():
return sys.stdin.readline().strip()
n, k, d = get_ints()
w = [0] * (n + 1)
w... | IMPORT ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR VAR NUMBER NUMBER FUNC_DEF RETURN FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR FUNC_DEF RETURN FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR FUNC_DEF RETURN FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR VAR FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER... |
Quite recently a creative student Lesha had a lecture on trees. After the lecture Lesha was inspired and came up with the tree of his own which he called a k-tree.
A k-tree is an infinite rooted tree where:
each vertex has exactly k children; each edge has some weight; if we look at the edges that goes from some ... | MOD = 10**9 + 7
HAVE, NOT_HAVE = 1, 0
n, k, d = map(int, input().split())
dp = [[(0) for _ in range(n + 1)] for _ in range(2)]
dp[NOT_HAVE][0] = 1
for dist in range(1, n + 1):
for weight in range(1, k + 1):
if weight > dist:
break
if weight >= d:
dp[HAVE][dist] += dp[HAVE][di... | ASSIGN VAR BIN_OP BIN_OP NUMBER NUMBER NUMBER ASSIGN VAR VAR NUMBER NUMBER ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER VAR FUNC_CALL VAR BIN_OP VAR NUMBER VAR FUNC_CALL VAR NUMBER ASSIGN VAR VAR NUMBER NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER ... |
Quite recently a creative student Lesha had a lecture on trees. After the lecture Lesha was inspired and came up with the tree of his own which he called a k-tree.
A k-tree is an infinite rooted tree where:
each vertex has exactly k children; each edge has some weight; if we look at the edges that goes from some ... | f, k, d = map(int, input().split())
a = [1]
b = [0]
mod = 1000000007
for i in range(1, f + 1):
m = n = 0
for j in range(1, k + 1):
if i - j > 0 and j < d:
m += a[i - j]
elif i - j > 0 and j >= d:
n += a[i - j]
if i - j > 0:
n += b[i - j]
if i >= d ... | ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST NUMBER ASSIGN VAR LIST NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER ASSIGN VAR VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER IF BIN_OP VAR VAR NUMBER VAR VAR VAR VAR BIN_OP VAR VAR IF BIN_OP VAR VAR NUMBE... |
Quite recently a creative student Lesha had a lecture on trees. After the lecture Lesha was inspired and came up with the tree of his own which he called a k-tree.
A k-tree is an infinite rooted tree where:
each vertex has exactly k children; each edge has some weight; if we look at the edges that goes from some ... | n, v, d = list(map(int, input().split()))
dp = [([0] * 2) for i in range(n + 1)]
dp[0][0] = 1
for i in range(1, n + 1):
for k in range(1, min(i, v) + 1):
dp[i][0] += dp[i - k][0]
if k >= d:
dp[i][1] += dp[i - k][0]
else:
dp[i][1] += dp[i - k][1]
print(dp[n][1] % (10**... | ASSIGN VAR VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER NUMBER VAR FUNC_CALL VAR BIN_OP VAR NUMBER ASSIGN VAR NUMBER NUMBER NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP FUNC_CALL VAR VAR VAR NUMBER VAR VAR NUMBER VAR BIN_OP VA... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.