結果
問題 | No.8081 HQ9+ |
ユーザー |
![]() |
提出日時 | 2021-04-01 20:16:35 |
言語 | Crystal (1.14.0) |
結果 |
AC
|
実行時間 | 2 ms / 2,000 ms |
コード長 | 440 bytes |
コンパイル時間 | 16,396 ms |
コンパイル使用メモリ | 295,892 KB |
実行使用メモリ | 6,820 KB |
最終ジャッジ日時 | 2024-12-18 01:47:55 |
合計ジャッジ時間 | 17,462 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 21 |
ソースコード
lib C fun strtoll(s : UInt8*, p : UInt8**, b : Int32) : Int64 end class String def to_i64 C.strtoll(self, nil, 10) end end n = read_line.to_i s = read_line if s.includes?('H') || s.includes?('9') puts -1; exit end cnt = s.count('Q') sq = Math.sqrt(cnt).to_i if cnt == 0 || sq ** 2 != cnt || n % sq != 0 puts -1; exit end len = n // sq t = s.chars.each_slice(len).to_a if t.uniq.size != 1 puts -1; exit end puts t[0].join