結果

問題 No.796 well known
ユーザー urutomurutom
提出日時 2019-04-04 01:08:07
言語 Ruby
(3.3.0)
結果
AC  
実行時間 808 ms / 2,000 ms
コード長 313 bytes
コンパイル時間 229 ms
コンパイル使用メモリ 11,456 KB
実行使用メモリ 101,604 KB
最終ジャッジ日時 2023-08-25 10:29:13
合計ジャッジ時間 7,898 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 80 ms
15,032 KB
testcase_01 AC 80 ms
15,292 KB
testcase_02 AC 82 ms
15,336 KB
testcase_03 AC 82 ms
15,156 KB
testcase_04 AC 425 ms
79,952 KB
testcase_05 AC 479 ms
87,432 KB
testcase_06 AC 808 ms
101,604 KB
testcase_07 AC 139 ms
30,180 KB
testcase_08 AC 483 ms
87,192 KB
testcase_09 AC 279 ms
60,844 KB
testcase_10 AC 608 ms
101,328 KB
testcase_11 AC 120 ms
24,116 KB
testcase_12 AC 220 ms
50,020 KB
testcase_13 AC 414 ms
80,244 KB
testcase_14 AC 177 ms
39,784 KB
testcase_15 AC 248 ms
56,772 KB
testcase_16 AC 628 ms
101,088 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

def check?(ans,n)
  return false unless ans.size==n
  return false if ans.any?{|v|v<1}
  sum=ans.inject(:+)
  return false unless sum%3==1
  prod=ans.inject(:*)
  return false unless prod%3==0
  sum<=312456
end

n=gets.to_i
ans=[]
loop{
  n.times{ans << rand(5)+1}
  break if check?(ans,n)
  ans=[]
}
puts ans*" "
0