結果

問題 No.152 貯金箱の消失
ユーザー simansiman
提出日時 2016-03-26 02:03:48
言語 Ruby
(3.3.0)
結果
AC  
実行時間 2,700 ms / 5,000 ms
コード長 342 bytes
コンパイル時間 124 ms
コンパイル使用メモリ 7,552 KB
実行使用メモリ 12,544 KB
最終ジャッジ日時 2024-04-09 23:54:46
合計ジャッジ時間 10,877 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 90 ms
12,160 KB
testcase_01 AC 104 ms
12,160 KB
testcase_02 AC 88 ms
12,160 KB
testcase_03 AC 92 ms
12,288 KB
testcase_04 AC 123 ms
12,288 KB
testcase_05 AC 125 ms
12,288 KB
testcase_06 AC 153 ms
12,416 KB
testcase_07 AC 497 ms
12,416 KB
testcase_08 AC 2,636 ms
12,544 KB
testcase_09 AC 2,700 ms
12,288 KB
testcase_10 AC 2,089 ms
12,288 KB
testcase_11 AC 1,201 ms
12,288 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

class Yukicoder
  def initialize
    l = gets.to_i
    limit = Math.sqrt(l)
    mod = 1000003

    answer = 0

    1.upto(limit-1) do |n|
      (n+1).upto(limit) do |m|
        if m.gcd(n) == 1 && [n,m].any?(&:even?) && (2*m*n + 2*m*m) <= l/4
          answer += 1
        end
      end
    end

    puts answer % mod
  end
end

Yukicoder.new
0