結果
| 問題 |
No.800 四平方定理
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2019-03-17 21:26:13 |
| 言語 | D (dmd 2.109.1) |
| 結果 |
AC
|
| 実行時間 | 1,759 ms / 2,000 ms |
| コード長 | 575 bytes |
| コンパイル時間 | 894 ms |
| コンパイル使用メモリ | 116,876 KB |
| 実行使用メモリ | 209,884 KB |
| 最終ジャッジ日時 | 2024-06-13 04:17:46 |
| 合計ジャッジ時間 | 21,838 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 30 |
ソースコード
import std.stdio, std.array, std.string, std.conv, std.algorithm;
import std.typecons, std.range, std.random, std.math, std.container;
import std.numeric, std.bigint, core.bitop, core.stdc.string;
void main() {
auto s = readln.split.map!(to!long);
auto N = s[0];
auto D = s[1];
long[long] cnt;
foreach (z; 1..N+1) foreach (w; 1..N+1) cnt[z*z-w*w] += 1;
long ans = 0;
foreach (x; 1..N+1) {
foreach (y; 1..N+1) {
if (D-x*x-y*y in cnt) {
ans += cnt[D-x*x-y*y];
}
}
}
ans.writeln;
}