結果
| 問題 |
No.152 貯金箱の消失
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2016-08-31 01:03:35 |
| 言語 | D (dmd 2.109.1) |
| 結果 |
AC
|
| 実行時間 | 272 ms / 5,000 ms |
| コード長 | 581 bytes |
| コンパイル時間 | 708 ms |
| コンパイル使用メモリ | 115,400 KB |
| 実行使用メモリ | 6,944 KB |
| 最終ジャッジ日時 | 2024-06-12 03:57:02 |
| 合計ジャッジ時間 | 2,126 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 12 |
コンパイルメッセージ
/home/linuxbrew/.linuxbrew/opt/dmd/include/dlang/dmd/std/numeric.d(2999): Warning: cannot inline function `std.numeric.gcdImpl!uint.gcdImpl`
ソースコード
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;
}