結果

問題 No.438 Cwwプログラミング入門
ユーザー mkawa2
提出日時 2020-04-24 14:52:15
言語 Python3
(3.13.1 + numpy 2.2.1 + scipy 1.14.1)
結果
WA  
実行時間 -
コード長 914 bytes
コンパイル時間 143 ms
コンパイル使用メモリ 12,544 KB
実行使用メモリ 17,576 KB
最終ジャッジ日時 2024-10-15 01:52:49
合計ジャッジ時間 4,284 ms
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2 WA * 1
other AC * 1 TLE * 1 -- * 96
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys

sys.setrecursionlimit(10 ** 5)
int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep="\n")
def II(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def SI(): return sys.stdin.readline()[:-1]

def extgcd(a,b,c):
    if b==0:return c//a,0,abs(a)
    x,y,g=extgcd(b,a%b,c)
    return y,x-y*(a//b),g

def main():
    mx=7
    x,y,z=MI()
    cx,cy,g=extgcd(x,y,z)
    if z%g:
        print("NO")
        exit()
    p=(cx>0)*2-1
    while (abs(cx)+abs(cy))*2-1>mx and (cx>0)*2-1==p:
        cx,cy=cx-p*y,cy+p*x
    if (abs(cx)+abs(cy))*2-1>mx:
        print("NO")
        exit()
    if cx>0:ans="c"+"cC"*(cx-1)+("w"+("C" if cy>0 else "W"))*abs(cy)
    else:ans="w"+"wC"*(cy-1)+("c"+("C" if cx>0 else "W"))*abs(cx)
    print(ans)

main()
0