Please sign in first.
Submission #6171699
Source Code Expand
import numpy as np
N,K = map(int,input().split())
MOD = 10 ** 9 + 7
M = int(N**.5)
# M+1以上で、商がぢょうとxになるやつ
upper_cnt = np.zeros(M+1, dtype=np.int64)
a = np.arange(M+1, dtype=np.int64)
upper_cnt[1:] = N // a[1:] - np.maximum(M, N // (a[1:]+1))
# 数列の末端ごとの個数
# upperについては、個数にわたって合計をとる
dp_lower = np.zeros((K+1,M+1), dtype=np.int64)
dp_upper = np.zeros((K+1,M+1), dtype=np.int64)
# 0項目に1を置いておくとする
dp_lower[0,1] = 1
for k in range(1,K+1):
prev_lower = dp_lower[k-1]
prev_upper = dp_upper[k-1]
cum_lower = prev_lower.cumsum() % MOD
cum_upper = prev_upper.cumsum() % MOD
# 下側 to 下側
dp_lower[k] += cum_lower[-1]
# 上側 to 下側
dp_lower[k] += cum_upper[-1]
dp_lower[k,1:] -= cum_upper[:-1] # 商がn-1以下だと受け付けない
dp_lower[k,0] = 0
# 上側 to 上側:ないはず
# 下側 to 上側:
dp_upper[k] = cum_lower * upper_cnt
dp_lower %= MOD
dp_upper %= MOD
answer = (dp_lower[K].sum() + dp_upper[K].sum()) % MOD
print(answer)
Submission Info
| Submission Time | |
|---|---|
| Task | F - Small Products |
| User | maspy |
| Language | Python (3.4.3) |
| Score | 0 |
| Code Size | 1154 Byte |
| Status | TLE |
| Exec Time | 2109 ms |
| Memory | 63700 KiB |
Judge Result
| Set Name | Sample | All | ||||||
|---|---|---|---|---|---|---|---|---|
| Score / Max Score | 0 / 0 | 0 / 600 | ||||||
| Status |
|
|
| Set Name | Test Cases |
|---|---|
| Sample | s1.txt, s2.txt, s3.txt |
| All | 01.txt, 02.txt, 03.txt, 04.txt, 05.txt, 06.txt, 09.txt, 10.txt, 11.txt, 12.txt, 13.txt, 14.txt, s1.txt, s2.txt, s3.txt |
| Case Name | Status | Exec Time | Memory |
|---|---|---|---|
| 01.txt | TLE | 2109 ms | 63700 KiB |
| 02.txt | TLE | 2109 ms | 56040 KiB |
| 03.txt | TLE | 2109 ms | 57484 KiB |
| 04.txt | TLE | 2109 ms | 59792 KiB |
| 05.txt | TLE | 2109 ms | 32780 KiB |
| 06.txt | AC | 150 ms | 12296 KiB |
| 09.txt | TLE | 2109 ms | 57236 KiB |
| 10.txt | AC | 148 ms | 12424 KiB |
| 11.txt | TLE | 2109 ms | 28408 KiB |
| 12.txt | AC | 1888 ms | 26872 KiB |
| 13.txt | AC | 1418 ms | 26744 KiB |
| 14.txt | AC | 150 ms | 12296 KiB |
| s1.txt | AC | 147 ms | 12296 KiB |
| s2.txt | AC | 146 ms | 12296 KiB |
| s3.txt | AC | 702 ms | 23264 KiB |