結果

問題 No.800 四平方定理
ユーザー LaFolia13LaFolia13
提出日時 2019-03-17 23:28:50
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
RE  
実行時間 -
コード長 661 bytes
コンパイル時間 1,481 ms
コンパイル使用メモリ 170,812 KB
実行使用メモリ 241,032 KB
最終ジャッジ日時 2023-09-22 11:36:08
合計ジャッジ時間 11,845 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 5 ms
5,396 KB
testcase_01 AC 6 ms
7,468 KB
testcase_02 AC 5 ms
6,152 KB
testcase_03 AC 7 ms
6,716 KB
testcase_04 AC 6 ms
5,916 KB
testcase_05 AC 6 ms
6,400 KB
testcase_06 AC 7 ms
8,596 KB
testcase_07 RE -
testcase_08 RE -
testcase_09 AC 8 ms
7,772 KB
testcase_10 AC 287 ms
120,876 KB
testcase_11 AC 315 ms
135,536 KB
testcase_12 AC 296 ms
133,284 KB
testcase_13 AC 272 ms
126,536 KB
testcase_14 AC 291 ms
135,652 KB
testcase_15 AC 302 ms
134,828 KB
testcase_16 AC 302 ms
137,132 KB
testcase_17 AC 312 ms
137,132 KB
testcase_18 AC 319 ms
136,384 KB
testcase_19 AC 317 ms
136,528 KB
testcase_20 AC 1 ms
4,376 KB
testcase_21 RE -
testcase_22 AC 332 ms
137,160 KB
testcase_23 AC 623 ms
241,032 KB
testcase_24 AC 592 ms
240,984 KB
testcase_25 AC 608 ms
240,284 KB
testcase_26 AC 1 ms
4,376 KB
testcase_27 RE -
testcase_28 AC 608 ms
239,800 KB
testcase_29 AC 609 ms
240,424 KB
testcase_30 AC 602 ms
239,988 KB
testcase_31 AC 552 ms
223,632 KB
testcase_32 AC 587 ms
240,912 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;
			for(auto &x : ok[check]){
				if(x.first == x.second)
					ans++;
				else
					ans += 2;
			}
		}

	cout << ans << endl;

	return 0;
}
0