結果

問題 No.152 貯金箱の消失
ユーザー te-shte-sh
提出日時 2016-08-31 01:03:35
言語 D
(dmd 2.107.1)
結果
AC  
実行時間 286 ms / 5,000 ms
コード長 581 bytes
コンパイル時間 649 ms
コンパイル使用メモリ 100,644 KB
実行使用メモリ 4,372 KB
最終ジャッジ日時 2023-09-02 21:41:50
合計ジャッジ時間 2,482 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,368 KB
testcase_01 AC 2 ms
4,368 KB
testcase_02 AC 1 ms
4,368 KB
testcase_03 AC 1 ms
4,368 KB
testcase_04 AC 4 ms
4,372 KB
testcase_05 AC 4 ms
4,368 KB
testcase_06 AC 7 ms
4,368 KB
testcase_07 AC 42 ms
4,368 KB
testcase_08 AC 283 ms
4,368 KB
testcase_09 AC 286 ms
4,372 KB
testcase_10 AC 221 ms
4,368 KB
testcase_11 AC 120 ms
4,372 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
/dmd2/linux/bin64/../../src/phobos/std/numeric.d(2999): Warning: cannot inline function `std.numeric.gcdImpl!uint.gcdImpl`

ソースコード

diff #

import std.algorithm, std.array, std.container, std.range;
import std.numeric, std.math, std.bigint, std.bitmanip, std.random;
import std.string, std.conv, std.stdio, std.typecons;

void main()
{
  auto l = readln.chomp.to!int;

  auto k = l / 4;
  auto max = l.to!real.sqrt.to!int;

  auto r = 0;
  foreach (m; 2..max)
    foreach (n; 1..m)
      if (isPitagolas(m, n) && sumPitagolas(m, n) <= k)
        r += 1;

  writeln(r);
}

bool isPitagolas(int m, int n)
{
  return gcd(m, n) == 1 && (m - n) % 2 == 1;
}

int sumPitagolas(int m, int n)
{
  return 2 * m ^^ 2 + 2 * m * n;
}
0