結果

問題 No.438 Cwwプログラミング入門
ユーザー convexineq
提出日時 2021-02-16 05:04:11
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 45 ms / 2,000 ms
コード長 527 bytes
コンパイル時間 191 ms
コンパイル使用メモリ 82,432 KB
実行使用メモリ 61,188 KB
最終ジャッジ日時 2024-07-23 20:46:18
合計ジャッジ時間 7,682 ms
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 98
権限があれば一括ダウンロードができます

ソースコード

diff #

def ans(A,B):
    if abs(A)+abs(B) > 5000: return
    cA,wB = "c"*abs(A),"w"*abs(B)
    if A >= 0 and B >= 0:
        return cA+wB+"C"*(A+B-1)
    if A >= 0:
        return wB+cA+"C"*(A-1)+"W"*(-B)
    if B >= 0:
        return cA+wB+"C"*(B-1)+"W"*(-A)

x,y,z = map(int,input().split())
if z==0:
    print("ccW")
    exit()

for A in range(-5000,5001):
    v = z-A*x
    if y and v%y: continue
    if y==0 and v: continue
    if y: B = v//y
    else: B = 0
    s = ans(A,B)
    if s:
        print(s)
        exit()
print("NO")
0