結果

問題 No.781 円周上の格子点の数え上げ
ユーザー startcppstartcpp
提出日時 2017-05-17 12:25:52
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 92 ms / 2,000 ms
コード長 445 bytes
コンパイル時間 407 ms
コンパイル使用メモリ 55,420 KB
実行使用メモリ 42,696 KB
最終ジャッジ日時 2023-10-17 14:43:20
合計ジャッジ時間 1,858 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,348 KB
testcase_01 AC 1 ms
4,348 KB
testcase_02 AC 2 ms
4,348 KB
testcase_03 AC 2 ms
4,348 KB
testcase_04 AC 2 ms
4,348 KB
testcase_05 AC 1 ms
4,348 KB
testcase_06 AC 1 ms
4,348 KB
testcase_07 AC 2 ms
4,348 KB
testcase_08 AC 86 ms
42,696 KB
testcase_09 AC 82 ms
42,696 KB
testcase_10 AC 2 ms
4,348 KB
testcase_11 AC 2 ms
4,348 KB
testcase_12 AC 87 ms
42,696 KB
testcase_13 AC 92 ms
42,696 KB
testcase_14 AC 3 ms
6,352 KB
testcase_15 AC 1 ms
4,348 KB
testcase_16 AC 2 ms
4,348 KB
testcase_17 AC 46 ms
26,832 KB
testcase_18 AC 39 ms
26,832 KB
testcase_19 AC 40 ms
28,880 KB
testcase_20 AC 40 ms
28,880 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

//4倍高速化
#include <iostream>
using namespace std;

int cnt[10000001];
int X, Y;

int main() {
	cin >> X >> Y;
	
	int maxR = 0; while (maxR * maxR <= Y) maxR++; maxR--;
	for (int x = 1; x <= maxR; x++) {
		for (int y = 0; y <= maxR; y++) {
			if (x * x + y * y <= Y) {
				cnt[x * x + y * y]++;
			}
		}
	}
	
	int ans = 0;
	for (int i = X; i <= Y; i++) {
		if (ans < cnt[i]) {
			ans = cnt[i];
		}
	}
	cout << ans * 4 << endl;
	return 0;
}
0