結果

問題 No.1198 お菓子配り-1
ユーザー simansiman
提出日時 2020-08-30 17:31:21
言語 Ruby
(3.3.0)
結果
TLE  
実行時間 -
コード長 424 bytes
コンパイル時間 642 ms
コンパイル使用メモリ 11,472 KB
実行使用メモリ 19,784 KB
最終ジャッジ日時 2023-08-09 17:16:43
合計ジャッジ時間 6,558 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 98 ms
19,752 KB
testcase_01 AC 99 ms
15,284 KB
testcase_02 AC 97 ms
15,296 KB
testcase_03 AC 95 ms
15,124 KB
testcase_04 AC 96 ms
15,300 KB
testcase_05 AC 98 ms
15,312 KB
testcase_06 AC 95 ms
15,404 KB
testcase_07 AC 97 ms
15,540 KB
testcase_08 AC 98 ms
15,160 KB
testcase_09 AC 98 ms
15,348 KB
testcase_10 AC 97 ms
15,148 KB
testcase_11 TLE -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
権限があれば一括ダウンロードができます
コンパイルメッセージ
Main.rb:26: warning: ambiguous first argument; put parentheses or a space even after `-' operator
Syntax OK

ソースコード

diff #

class Integer
  def divisor_list
    require 'prime'

    return [] if self <= 0
    return [1] if self == 1

    prime_division.map.with_index { |(base, k), i|
      s = i.zero? ? 0 : 1
      (s..k).map { |n| base ** n }
    }.inject { |res, e| res + res.flat_map { |t| e.map { |v| t * v } } }.sort
  end
end

N = gets.to_i

N.divisor_list.each do |c|
  d = N / c

  if (c + d).even?
    puts 1
    exit
  end
end

puts -1
0