結果

問題 No.3081 Make Palindromic Multiple
ユーザー gew1fw
提出日時 2025-06-12 13:01:36
言語 PyPy3
(7.3.15)
結果
RE  
実行時間 -
コード長 1,109 bytes
コンパイル時間 212 ms
コンパイル使用メモリ 82,816 KB
実行使用メモリ 65,664 KB
最終ジャッジ日時 2025-06-12 13:08:04
合計ジャッジ時間 12,054 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample RE * 3
other RE * 54
権限があれば一括ダウンロードができます

ソースコード

diff #

def generate_99_bottles():
    s = []
    for i in range(99, 0, -1):
        line1 = f"{i} bottle{'s' if i != 1 else ''} of beer on the wall, {i} bottle{'s' if i != 1 else ''} of beer."
        line2 = f"Take one down and pass it around, {i-1} bottle{'s' if (i-1) != 1 else ''} of beer on the wall."
        s.append(line1)
        s.append(line2)
        s.append("")
    s.append("No more bottles of beer on the wall, no more bottles of beer.")
    s.append("Go to the store and buy some more, 99 bottles of beer on the wall.")
    return '\n'.join(s)

n = int(input())
s = input().strip()

if s == "Hello, World!":
    print("H")
else:
    song = generate_99_bottles()
    if s == song:
        print("9")
    else:
        q_count = s.count('Q')
        if q_count == 1:
            valid = True
            for c in s:
                if c == 'Q':
                    continue
                if c in {'H', 'Q', '9'}:
                    valid = False
                    break
            if valid:
                print(s)
            else:
                print(-1)
        else:
            print(-1)
0