結果
問題 | No.8081 HQ9+ |
ユーザー |
|
提出日時 | 2021-04-15 10:33:44 |
言語 | Ruby (3.4.1) |
結果 |
AC
|
実行時間 | 95 ms / 2,000 ms |
コード長 | 326 bytes |
コンパイル時間 | 58 ms |
コンパイル使用メモリ | 7,680 KB |
実行使用メモリ | 12,416 KB |
最終ジャッジ日時 | 2024-07-01 10:07:01 |
合計ジャッジ時間 | 2,963 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 21 |
コンパイルメッセージ
Main.rb:16: warning: ambiguous first argument; put parentheses or a space even after `-' operator Main.rb:20: warning: ambiguous first argument; put parentheses or a space even after `-' operator Syntax OK
ソースコード
class Integer def isqrt return 0 if self<=0 return 1 if self<4 # 1 x,y=0,self while x!=y&&x+1!=y x,y=y,(self/y+y)/2 end x end end n=gets.to_i s=gets.chomp c=s.count 'Q' if s.include?('H')||c<1||c.isqrt**2!=c p -1;exit end a=s.chars.each_slice(n/c.isqrt).to_a if a.any?{|e|e!=a[0]} p -1;exit end puts a[0]*''