結果

問題 No.2198 Concon Substrings (COuNt-CONstruct Version)
ユーザー lam6er
提出日時 2025-04-16 16:45:35
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 1,118 bytes
コンパイル時間 450 ms
コンパイル使用メモリ 82,044 KB
実行使用メモリ 59,616 KB
最終ジャッジ日時 2025-04-16 16:47:11
合計ジャッジ時間 14,752 ms
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 52 WA * 52
権限があれば一括ダウンロードができます

ソースコード

diff #

def find_concon(M):
    if M == 0:
        return "kudamakitsukasa"
    
    # Check if M is a tetrahedral number
    target = 6 * M
    low = 1
    high = 2 * 10**6  # Sufficiently large upper bound
    k = -1
    while low <= high:
        mid = (low + high) // 2
        product = mid * (mid + 1) * (mid + 2)
        if product == target:
            k = mid
            break
        elif product < target:
            low = mid + 1
        else:
            high = mid - 1
    if k != -1:
        return "con" * k
    
    # If not, use the product approach
    max_a = min(10**4, M)
    for a in range(max_a, 0, -1):
        if M % a != 0:
            continue
        remaining = M // a
        max_b = min(10**4, remaining)
        for b in range(max_b, 0, -1):
            if remaining % b != 0:
                continue
            c = remaining // b
            if a + b + c <= 60000:
                return "c" * a + "o" * b + "n" * c
    
    # If all else fails (as per problem statement, this won't happen)
    return "c"  # This line is theoretically unreachable

M = int(input())
print(find_concon(M))
0