結果

問題 No.800 四平方定理
ユーザー ats5515ats5515
提出日時 2019-03-17 23:14:19
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 44 ms / 2,000 ms
コード長 640 bytes
コンパイル時間 883 ms
コンパイル使用メモリ 84,508 KB
実行使用メモリ 24,164 KB
最終ジャッジ日時 2023-09-22 10:18:09
合計ジャッジ時間 2,192 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 AC 2 ms
4,376 KB
testcase_04 AC 2 ms
4,380 KB
testcase_05 AC 2 ms
4,380 KB
testcase_06 AC 2 ms
4,380 KB
testcase_07 AC 2 ms
4,380 KB
testcase_08 AC 2 ms
4,380 KB
testcase_09 AC 2 ms
4,380 KB
testcase_10 AC 17 ms
13,864 KB
testcase_11 AC 16 ms
13,584 KB
testcase_12 AC 16 ms
15,632 KB
testcase_13 AC 13 ms
11,552 KB
testcase_14 AC 15 ms
13,792 KB
testcase_15 AC 17 ms
15,744 KB
testcase_16 AC 15 ms
13,676 KB
testcase_17 AC 16 ms
13,860 KB
testcase_18 AC 20 ms
17,760 KB
testcase_19 AC 20 ms
17,696 KB
testcase_20 AC 1 ms
4,380 KB
testcase_21 AC 1 ms
4,380 KB
testcase_22 AC 20 ms
18,012 KB
testcase_23 AC 43 ms
24,028 KB
testcase_24 AC 35 ms
19,740 KB
testcase_25 AC 44 ms
24,164 KB
testcase_26 AC 2 ms
4,380 KB
testcase_27 AC 2 ms
5,404 KB
testcase_28 AC 35 ms
19,732 KB
testcase_29 AC 39 ms
21,784 KB
testcase_30 AC 33 ms
19,856 KB
testcase_31 AC 31 ms
19,932 KB
testcase_32 AC 35 ms
19,744 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <vector>
#include <map>
#include <unordered_map>
#include <set>
#include <queue>
#include <string>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <stdio.h>
using namespace std;
int MOD = 1000000007;
int mp[8001000];
signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int N, D;
	cin >> N >> D;
	for (int i = 1; i <= N; i++) {
		for (int j = 1; j <= N; j++) {
			int t = i * i - j * j + D;
			if (t < 0)break;
			mp[t]++;
		}
	}
	long long res = 0;
	for (int i = 1; i <= N; i++) {
		for (int j = 1; j <= N; j++) {
			res += (long long)mp[i * i + j * j];
		}
	}

	cout << res << endl;
}
0