結果

問題 No.781 円周上の格子点の数え上げ
ユーザー iicafiaxusiicafiaxus
提出日時 2019-01-11 22:33:40
言語 D
(dmd 2.099.1)
結果
AC  
実行時間 955 ms / 2,000 ms
コード長 774 bytes
コンパイル時間 1,803 ms
使用メモリ 114,212 KB
最終ジャッジ日時 2023-01-06 18:05:17
合計ジャッジ時間 8,462 ms
ジャッジサーバーID
(参考情報)
judge15 / judge16
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
使用メモリ
testcase_00 AC 2 ms
3,516 KB
testcase_01 AC 1 ms
3,480 KB
testcase_02 AC 1 ms
3,476 KB
testcase_03 AC 2 ms
3,336 KB
testcase_04 AC 1 ms
3,512 KB
testcase_05 AC 2 ms
3,464 KB
testcase_06 AC 6 ms
3,752 KB
testcase_07 AC 11 ms
4,208 KB
testcase_08 AC 943 ms
114,176 KB
testcase_09 AC 928 ms
114,212 KB
testcase_10 AC 3 ms
3,520 KB
testcase_11 AC 6 ms
3,712 KB
testcase_12 AC 955 ms
114,172 KB
testcase_13 AC 952 ms
114,116 KB
testcase_14 AC 48 ms
9,440 KB
testcase_15 AC 4 ms
3,440 KB
testcase_16 AC 4 ms
3,524 KB
testcase_17 AC 552 ms
62,852 KB
testcase_18 AC 548 ms
62,780 KB
testcase_19 AC 566 ms
64,292 KB
testcase_20 AC 566 ms
64,272 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import std.stdio, std.conv, std.string, std.bigint;
import std.math, std.random, std.datetime;
import std.array, std.range, std.algorithm, std.container, std.format;
string read(){ static string[] ss; while(!ss.length) ss = readln.chomp.split; string res = ss[0]; ss.popFront; return res; }

void main(){
	int x = read.to!int;
	int y = read.to!int;
	
	int[] qs;
	for(int a = 0; a <= y; a ++){
		qs ~= a * a;
	}
	
	int[] count;
	for(int r = 0; r <= y; r ++){
		count ~= 0;
	}
	
	
	int bmax = y;
	for(int a = 0; qs[a] <= y; a ++){
		int r;
		for(int b = 1; qs[b] <= y; b ++){
			r = qs[a] + qs[b];
			if(r > y) break;
			count[r] += 1;
		}
	}
	
	int countmax = 0;
	for(int r = x; r <= y; r ++){
		if(count[r] > countmax) countmax = count[r];
	}
	
	(countmax * 4).writeln;
	
}
0