結果

問題 No.8081 HQ9+
ユーザー roarisroaris
提出日時 2021-04-01 21:18:39
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 42 ms / 2,000 ms
コード長 264 bytes
コンパイル時間 260 ms
コンパイル使用メモリ 82,380 KB
実行使用メモリ 54,380 KB
最終ジャッジ日時 2024-12-21 05:33:03
合計ジャッジ時間 1,809 ms
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 21
権限があれば一括ダウンロードができます

ソースコード

diff #

N = int(input())
S = input()

if 'H' in S or '9' in S or '+' in S:
    print(-1)
    exit()
    
Q = S.count('Q')

if Q==0:
    print(-1)
    exit()
    
x = -1

for i in range(Q+1):
    if i*i==Q:
        x = i

if x==-1:
    print(-1)
    exit()

print(S[:N//x])
0