結果
| 問題 |
No.3081 Make Palindromic Multiple
|
| コンテスト | |
| ユーザー |
gew1fw
|
| 提出日時 | 2025-06-12 19:01:00 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
RE
|
| 実行時間 | - |
| コード長 | 1,233 bytes |
| コンパイル時間 | 250 ms |
| コンパイル使用メモリ | 82,176 KB |
| 実行使用メモリ | 67,420 KB |
| 最終ジャッジ日時 | 2025-06-12 19:01:32 |
| 合計ジャッジ時間 | 12,518 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | RE * 3 |
| other | RE * 54 |
ソースコード
import math
def generate_99_bottles_lyrics():
lyrics = []
for n in range(99, -1, -1):
if n > 0:
bottles_current = f"{n} bottle{'s' if n != 1 else ''} of beer"
line1 = f"{bottles_current} on the wall, {bottles_current}."
if n == 1:
line2 = "Take one down and pass it around, no more bottles of beer on the wall."
else:
next_n = n - 1
bottles_next = f"{next_n} bottle{'s' if next_n != 1 else ''} of beer"
line2 = f"Take one down and pass it around, {bottles_next} on the wall."
else:
line1 = "No more bottles of beer on the wall, no more bottles of beer."
line2 = "Go to the store and buy some more, 99 bottles of beer on the wall."
verse = f"{line1}\n{line2}\n"
lyrics.append(verse)
return ''.join(lyrics)
n = int(input())
s = input().strip()
hello = "Hello, World!"
if s == hello:
print("H")
elif s == "Q":
print("Q")
elif s == generate_99_bottles_lyrics():
print("9")
elif all(c == 'Q' for c in s):
m = len(s)
root = math.isqrt(m)
if root * root == m:
print('Q' * root)
else:
print(-1)
else:
print(-1)
gew1fw