結果

問題 No.800 四平方定理
ユーザー lapilapi
提出日時 2019-04-18 21:08:27
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 117 ms / 2,000 ms
コード長 900 bytes
コンパイル時間 1,247 ms
コンパイル使用メモリ 104,272 KB
実行使用メモリ 57,672 KB
最終ジャッジ日時 2023-10-23 16:24:14
合計ジャッジ時間 4,796 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 8 ms
7,892 KB
testcase_01 AC 8 ms
8,040 KB
testcase_02 AC 8 ms
7,948 KB
testcase_03 AC 8 ms
7,972 KB
testcase_04 AC 8 ms
7,960 KB
testcase_05 AC 8 ms
7,992 KB
testcase_06 AC 8 ms
8,084 KB
testcase_07 AC 8 ms
8,268 KB
testcase_08 AC 9 ms
9,732 KB
testcase_09 AC 8 ms
8,040 KB
testcase_10 AC 42 ms
32,980 KB
testcase_11 AC 42 ms
35,028 KB
testcase_12 AC 47 ms
35,028 KB
testcase_13 AC 39 ms
30,932 KB
testcase_14 AC 39 ms
32,980 KB
testcase_15 AC 47 ms
35,028 KB
testcase_16 AC 43 ms
32,980 KB
testcase_17 AC 41 ms
32,980 KB
testcase_18 AC 53 ms
37,076 KB
testcase_19 AC 50 ms
37,076 KB
testcase_20 AC 7 ms
5,636 KB
testcase_21 AC 7 ms
5,636 KB
testcase_22 AC 50 ms
37,076 KB
testcase_23 AC 117 ms
57,672 KB
testcase_24 AC 81 ms
53,576 KB
testcase_25 AC 95 ms
57,636 KB
testcase_26 AC 7 ms
5,636 KB
testcase_27 AC 8 ms
7,684 KB
testcase_28 AC 83 ms
53,520 KB
testcase_29 AC 87 ms
55,600 KB
testcase_30 AC 82 ms
53,528 KB
testcase_31 AC 76 ms
51,412 KB
testcase_32 AC 80 ms
53,576 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <set>
#include <map>
#include <numeric>
#include <regex>
#include <tuple>
#include<iomanip>
using namespace std;

typedef long long ll;
typedef pair<int, int> P;
#define MOD 1000000007 // 10^9 + 7
#define INF 1000000000 // 10^9
#define LLINF 1LL<<60

int xy[8000009]; // xy[i] : x^2+y^2 = iとなる(x,y)の組
int wz[8000009]; // 

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);

	int N, D; cin >> N >> D;

	//for (int i = 1; i <= 8000000; i++) xy[i] = wz[i] = 0;
	for (int i = 1; i <= N; i++) {
		for (int j = 1; j <= N; j++) {
			xy[i * i + j * j]++;
			if (1<= i * i - j * j + D && i * i - j * j + D <= 8000000) wz[i * i - j * j + D]++;
		}
	}

	ll ans = 0;
	for (int i = 1; i <= 8000000; i++) ans += xy[i] * wz[i];
	cout << ans << endl;

	return 0;
}
0