結果

問題 No.438 Cwwプログラミング入門
ユーザー 🍡yurahuna
提出日時 2016-05-05 21:58:04
言語 Python3
(3.13.1 + numpy 2.2.1 + scipy 1.14.1)
結果
WA  
実行時間 -
コード長 1,187 bytes
コンパイル時間 404 ms
コンパイル使用メモリ 12,800 KB
実行使用メモリ 10,880 KB
最終ジャッジ日時 2024-11-24 18:13:39
合計ジャッジ時間 6,955 ms
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 95 WA * 3
権限があれば一括ダウンロードができます

ソースコード

diff #

c = 'c'; w = 'w'; C = 'C'; W = 'W'
MAX = 10000

def dame():
    print("mourennaihasimasenn")
    exit() # <----------!!!!!!!!!

x, y, z = map(int, input().split())
if x < y:
    # x >= y となるようにそろえる
    # cとwの中身も入れ替える
    x, y = y, x
    c, w = w, c

if z == 0:
    # x - x = 0
    print('ccW')
    exit()
elif x == y == 0:
    dame()
elif y == 0:
    if z % x != 0:
        dame()
    nc = z // x
    nC = nc - 1
    if nc + nC > MAX:
        dame()
    else:
        print(c * nc + C * nC)
        exit()
else:
    # cの個数が正だとして全探索
    for nc in range(1, MAX):
        nC = nc - 1

        # 対応する整数nwが存在しなければ次のncへ
        if (z - x * nc) % y != 0:
            continue

        nw = (z - x * nc) // y
        nW = 0
        if nw > 0:
            # +y+y...
            nC += nw
        elif nw < 0:
            # -y-y...
            nw = -nw
            nW += nw

        if nc + nw + nW + nC <= MAX:
            # c-w は wcW なので、wを先に入れておく
            print(w * nw + c * nc + C * nC + W * nW)
            exit()

    # 見つからなかったらダメ
    dame()
0