結果
問題 |
No.3081 Make Palindromic Multiple
|
ユーザー |
![]() |
提出日時 | 2025-04-15 21:21:15 |
言語 | PyPy3 (7.3.15) |
結果 |
RE
|
実行時間 | - |
コード長 | 1,730 bytes |
コンパイル時間 | 176 ms |
コンパイル使用メモリ | 81,684 KB |
実行使用メモリ | 67,136 KB |
最終ジャッジ日時 | 2025-04-15 21:27:19 |
合計ジャッジ時間 | 11,853 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | RE * 3 |
other | RE * 54 |
ソースコード
n = int(input()) s = input().strip() def generate_99_song(): song = [] for i in range(99, 0, -1): part1 = f"{i} bottle{'s' if i != 1 else ''} of beer on the wall, {i} bottle{'s' if i != 1 else ''} of beer." song.append(part1) part2 = "Take one down and pass it around, " if i - 1 == 0: part2 += "no more bottles of beer on the wall." else: part2 += f"{i-1} bottle{'s' if (i-1) != 1 else ''} of beer on the wall." song.append(part2) song.append("\n") song.append("No more bottles of beer on the wall, no more bottles of beer.\n") song.append("Go to the store and buy some more, 99 bottles of beer on the wall.\n") return ''.join(song) song_99 = generate_99_song() if s == song_99: print('9') elif s == "Hello, world!": print('H') else: q_count = s.count('Q') other_commands = any(c in 'H9+' for c in s) if q_count == 1 and not other_commands: print(s) else: divisors = [] for m in range(1, int(n**0.5) + 1): if n % m == 0: divisors.append(m) if m != n // m: divisors.append(n // m) divisors.sort() found = False for m in divisors: if n % m != 0: continue k = n // m candidate = s[:k] if candidate * m != s: continue q_candidate = candidate.count('Q') if q_candidate != m: continue if any(c in 'H9+' for c in candidate): continue print(candidate) found = True break if not found: print(-1)