結果
| 問題 |
No.1383 Numbers of Product
|
| コンテスト | |
| ユーザー |
gew1fw
|
| 提出日時 | 2025-06-12 20:34:49 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 2,047 bytes |
| コンパイル時間 | 261 ms |
| コンパイル使用メモリ | 81,932 KB |
| 実行使用メモリ | 55,684 KB |
| 最終ジャッジ日時 | 2025-06-12 20:35:35 |
| 合計ジャッジ時間 | 4,608 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 5 TLE * 1 -- * 45 |
ソースコード
import math
from collections import defaultdict
def main():
N, K, M = map(int, input().split())
count = defaultdict(int)
L = 2
while True:
min_product = 1
for i in range(L):
term = 1 + i * K
if term > N:
min_product = N + 1
break
min_product *= term
if min_product > N:
break
if min_product > N:
break
low = 1
high = N
A_max = 0
while low <= high:
mid = (low + high) // 2
product = 1
valid = True
for i in range(L):
term = mid + i * K
if term > N:
valid = False
break
if product > N // term:
valid = False
break
product *= term
if product > N:
valid = False
break
if valid:
A_max = mid
low = mid + 1
else:
high = mid - 1
if A_max == 0:
L += 1
continue
current_A = 1
while current_A <= A_max:
product = 1
overflow = False
for i in range(L):
term = current_A + i * K
if term > N:
overflow = True
break
if product > N // term:
overflow = True
break
product *= term
if product > N:
overflow = True
break
if overflow:
current_A += 1
continue
count[product] += 1
current_A += 1
L += 1
result = 0
for x in count:
if x <= N and count[x] == M:
result += 1
print(result)
if __name__ == "__main__":
main()
gew1fw