結果
| 問題 |
No.2198 Concon Substrings (COuNt-CONstruct Version)
|
| コンテスト | |
| ユーザー |
gew1fw
|
| 提出日時 | 2025-06-12 15:04:31 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,259 bytes |
| コンパイル時間 | 411 ms |
| コンパイル使用メモリ | 82,288 KB |
| 実行使用メモリ | 838,620 KB |
| 最終ジャッジ日時 | 2025-06-12 15:05:25 |
| 合計ジャッジ時間 | 3,992 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 18 WA * 2 MLE * 1 -- * 83 |
ソースコード
import math
def find_k(M):
approx = (6 * M) ** (1/3)
k = int(approx)
for delta in [-1, 0, 1]:
current_k = k + delta
if current_k < 0:
continue
if current_k * (current_k + 1) * (current_k + 2) // 6 == M:
return current_k
return None
def minimal_abc(M):
min_sum = float('inf')
best = (1, 1, M)
max_a = int(math.isqrt(M)) + 1
for a in range(1, max_a + 1):
if M % a != 0:
continue
q = M // a
b = int(math.isqrt(q))
for delta in [-1, 0, 1]:
current_b = b + delta
if current_b <= 0:
continue
if q % current_b != 0:
continue
current_c = q // current_b
current_sum = a + current_b + current_c
if current_sum < min_sum:
min_sum = current_sum
best = (a, current_b, current_c)
return best
def main():
M = int(input().strip())
if M == 0:
print("kudamakitsukasa")
return
k = find_k(M)
if k is not None:
s = "con" * k
print(s)
return
a, b, c = minimal_abc(M)
s = 'c' * a + 'o' * b + 'n' * c
print(s)
if __name__ == "__main__":
main()
gew1fw