結果

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

ソースコード

diff #

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

def dame():
    print("mourennaihasimasenn")

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')
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)
else:
    # cの個数について全探索
    for nc in range(1, MAX):
        nC1 = nc - 1    # cの直後に置くC
        nC2 = 0         # wの直後に置くC

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

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

        if nc + nC1 + nw + nC2 + nW <= MAX:
            # print(nc, nC1, nw, nC2, nW)
            print(c * nc + C * nC1 + w * nw + C * nC2 + W * nW)
            exit()

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