結果

問題 No.800 四平方定理
ユーザー LaFolia13LaFolia13
提出日時 2019-03-17 23:34:46
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 617 ms / 2,000 ms
コード長 696 bytes
コンパイル時間 1,592 ms
コンパイル使用メモリ 170,760 KB
実行使用メモリ 241,020 KB
最終ジャッジ日時 2023-09-22 14:09:47
合計ジャッジ時間 10,974 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 5 ms
5,516 KB
testcase_01 AC 7 ms
7,496 KB
testcase_02 AC 6 ms
6,248 KB
testcase_03 AC 6 ms
6,712 KB
testcase_04 AC 6 ms
5,988 KB
testcase_05 AC 7 ms
6,476 KB
testcase_06 AC 9 ms
8,564 KB
testcase_07 AC 7 ms
6,964 KB
testcase_08 AC 8 ms
8,476 KB
testcase_09 AC 7 ms
7,736 KB
testcase_10 AC 290 ms
120,968 KB
testcase_11 AC 311 ms
135,640 KB
testcase_12 AC 309 ms
133,312 KB
testcase_13 AC 298 ms
126,588 KB
testcase_14 AC 310 ms
135,620 KB
testcase_15 AC 316 ms
134,772 KB
testcase_16 AC 296 ms
137,084 KB
testcase_17 AC 300 ms
136,940 KB
testcase_18 AC 322 ms
136,496 KB
testcase_19 AC 320 ms
136,696 KB
testcase_20 AC 2 ms
4,376 KB
testcase_21 AC 1 ms
4,376 KB
testcase_22 AC 335 ms
136,936 KB
testcase_23 AC 617 ms
241,020 KB
testcase_24 AC 579 ms
240,884 KB
testcase_25 AC 602 ms
240,100 KB
testcase_26 AC 1 ms
4,376 KB
testcase_27 AC 1 ms
4,376 KB
testcase_28 AC 579 ms
239,820 KB
testcase_29 AC 587 ms
240,308 KB
testcase_30 AC 588 ms
240,112 KB
testcase_31 AC 540 ms
223,412 KB
testcase_32 AC 607 ms
240,884 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>

using namespace std;
using llong = long long;
using ldbl = long double;
using P = pair<llong, llong>;

#define BE(x) x.begin(), x.end()

const llong inf = llong(1e18)+7;
const llong mod = 1e9+7;


int main(){
	int N, D;
	cin >> N >> D;

	int ans = 0;
	vector<vector<P>> ok(N*N*2+1);
	for(int i = 1; i <= N; i++)
		for(int j = i; j <= N; j++)
			ok[i*i+j*j].push_back(P(i,j));

	for(int i = 1; i <= N; i++)
		for(int j = 1; j <= N; j++){
			int check = D - (j*j - i*i);
			if(check < 0)
				break;
			if(check > N*N*2)
				continue;
			for(auto &x : ok[check]){
				if(x.first == x.second)
					ans++;
				else
					ans += 2;
			}
		}

	cout << ans << endl;

	return 0;
}
0