結果

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

ソースコード

diff #

def generate_99_bottles():
    bottles = 99
    lines = []
    while bottles > 0:
        lines.append(f"{bottles} bottles of beer on the wall, {bottles} bottles of beer.")
        lines.append("Take one down and pass it around,")
        if bottles == 1:
            lines.append("No more bottles of beer on the wall.")
        else:
            lines.append(f"{bottles - 1} bottles of beer on the wall.")
        lines.append("")  # Empty line between verses
        bottles -= 1
    lines.append("No more bottles of beer on the wall, no more bottles of beer.")
    lines.append("Go to the store and buy some more, 99 bottles of beer on the wall.")
    return '\n'.join(lines)

ninety_nine_bottles = generate_99_bottles()

N = int(input())
S = input().strip()

if S == "Hello, World!":
    print("H")
elif S == ninety_nine_bottles:
    print("9")
elif len(S) > 0 and S[0] == 'Q':
    # Check if all characters after the first are not HQ+9 commands
    valid = True
    for c in S[1:]:
        if c in {'H', 'Q', '9', '+'}:
            valid = False
            break
    if valid:
        print(S)
    else:
        print(-1)
else:
    print(-1)
0