結果
問題 | No.781 円周上の格子点の数え上げ |
ユーザー | nanae |
提出日時 | 2019-01-11 22:09:24 |
言語 | D (dmd 2.107.1) |
結果 |
AC
|
実行時間 | 1,166 ms / 2,000 ms |
コード長 | 1,950 bytes |
コンパイル時間 | 2,263 ms |
コンパイル使用メモリ | 93,044 KB |
実行使用メモリ | 209,156 KB |
最終ジャッジ日時 | 2023-09-03 21:59:36 |
合計ジャッジ時間 | 4,855 ms |
ジャッジサーバーID (参考情報) |
judge15 / judge13 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 42 ms
4,380 KB |
testcase_01 | AC | 42 ms
4,376 KB |
testcase_02 | AC | 42 ms
4,384 KB |
testcase_03 | AC | 43 ms
4,380 KB |
testcase_04 | AC | 42 ms
4,380 KB |
testcase_05 | AC | 42 ms
4,380 KB |
testcase_06 | AC | 42 ms
4,380 KB |
testcase_07 | AC | 42 ms
4,380 KB |
testcase_08 | AC | 43 ms
4,376 KB |
testcase_09 | AC | 42 ms
4,380 KB |
testcase_10 | AC | 43 ms
4,384 KB |
testcase_11 | AC | 45 ms
4,376 KB |
testcase_12 | AC | 549 ms
64,104 KB |
testcase_13 | AC | 1,166 ms
209,156 KB |
testcase_14 | AC | 49 ms
5,896 KB |
testcase_15 | AC | 42 ms
4,376 KB |
testcase_16 | AC | 43 ms
4,380 KB |
testcase_17 | AC | 593 ms
64,328 KB |
testcase_18 | AC | 42 ms
4,376 KB |
testcase_19 | AC | 42 ms
4,380 KB |
testcase_20 | AC | 43 ms
4,384 KB |
ソースコード
import std.stdio, std.string, std.conv; import std.range, std.algorithm, std.array, std.typecons, std.container; import std.math, std.numeric, core.bitop; enum mod = 10L ^^ 9 + 7; void main() { int x, y; scan(x, y); int[int] sq; /* foreach (i ; 0 .. 10^^4) { sq[i*i] = i; } */ int ans; foreach (i ; 0 .. 10^^4) { foreach (j ; 0 .. i + 1) { int d = i*i + j*j; if (d < x || d > y) continue; debug { writefln("i, j, d = %d, %d, %d", i, j, d); } if (i == 0 || j == 0 || i == j) { sq[d] += 4; } else { sq[d] += 8; } ans = max(ans, sq[d]); } } /+ foreach (r ; x .. y + 1) { int tmp; foreach (i ; 0 .. r) { int d = r - i*i; if (d < 0) { break; } if (!(d in sq)) { continue; } int j = sq[d]; if (i > j) { break; } debug { writefln("(i, j) = (%d, %d)", i, j); } if (i == j || i == 0) { tmp += 4; } else { tmp += 8; } } ans = max(ans, tmp); } +/ writeln(ans); } void scan(T...)(ref T args) { import std.stdio : readln; import std.algorithm : splitter; import std.conv : to; import std.range.primitives; auto line = readln().splitter(); foreach (ref arg; args) { arg = line.front.to!(typeof(arg)); line.popFront(); } assert(line.empty); } void fillAll(R, T)(ref R arr, T value) { static if (is(typeof(arr[] = value))) { arr[] = value; } else { foreach (ref e; arr) { fillAll(e, value); } } }