結果

問題 No.800 四平方定理
ユーザー yuma220284yuma220284
提出日時 2020-02-10 09:55:56
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 1,408 ms / 2,000 ms
コード長 490 bytes
コンパイル時間 1,693 ms
コンパイル使用メモリ 165,256 KB
実行使用メモリ 36,276 KB
最終ジャッジ日時 2024-04-08 12:49:24
合計ジャッジ時間 18,764 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 8 ms
6,676 KB
testcase_01 AC 16 ms
6,676 KB
testcase_02 AC 11 ms
6,676 KB
testcase_03 AC 12 ms
6,676 KB
testcase_04 AC 11 ms
6,676 KB
testcase_05 AC 12 ms
6,676 KB
testcase_06 AC 17 ms
6,676 KB
testcase_07 AC 17 ms
6,676 KB
testcase_08 AC 12 ms
6,676 KB
testcase_09 AC 15 ms
6,676 KB
testcase_10 AC 617 ms
19,888 KB
testcase_11 AC 616 ms
36,276 KB
testcase_12 AC 696 ms
36,276 KB
testcase_13 AC 476 ms
19,888 KB
testcase_14 AC 527 ms
36,276 KB
testcase_15 AC 697 ms
36,276 KB
testcase_16 AC 528 ms
36,276 KB
testcase_17 AC 531 ms
36,276 KB
testcase_18 AC 819 ms
36,276 KB
testcase_19 AC 818 ms
36,276 KB
testcase_20 AC 2 ms
6,676 KB
testcase_21 AC 2 ms
6,676 KB
testcase_22 AC 820 ms
36,276 KB
testcase_23 AC 1,398 ms
36,276 KB
testcase_24 AC 999 ms
36,276 KB
testcase_25 AC 1,408 ms
36,276 KB
testcase_26 AC 1 ms
6,676 KB
testcase_27 AC 1 ms
6,676 KB
testcase_28 AC 1,012 ms
36,276 KB
testcase_29 AC 1,238 ms
36,276 KB
testcase_30 AC 1,006 ms
36,276 KB
testcase_31 AC 939 ms
36,276 KB
testcase_32 AC 1,067 ms
36,276 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include "bits/stdc++.h"
using namespace std;

int main() {
	long long N, D;
	cin >> N >> D;
	vector<long long> V;
	for (int i = 1; i <= N; i++) {
		for (int j = 1; j <= N; j++) V.push_back(i * i + j * j);
	}
	sort(V.begin(), V.end());
	long long ANS = 0;
	for (int i = 1; i <= N; i++) {
		for (int j = 1; j <= N; j++) {
			if (i * i + D >= j * j) ANS += upper_bound(V.begin(), V.end(), i * i + D - j * j) - lower_bound(V.begin(), V.end(), i * i + D - j * j);
		}
	}
	cout << ANS << endl;
}
0