結果

問題 No.800 四平方定理
ユーザー LaFolia13LaFolia13
提出日時 2019-03-17 23:30:41
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 676 bytes
コンパイル時間 1,580 ms
コンパイル使用メモリ 170,860 KB
実行使用メモリ 241,304 KB
最終ジャッジ日時 2023-09-22 13:54:34
合計ジャッジ時間 11,218 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 AC 319 ms
135,604 KB
testcase_15 WA -
testcase_16 AC 320 ms
136,904 KB
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 AC 598 ms
240,864 KB
testcase_25 WA -
testcase_26 AC 2 ms
4,376 KB
testcase_27 AC 2 ms
4,380 KB
testcase_28 AC 588 ms
239,744 KB
testcase_29 WA -
testcase_30 AC 595 ms
240,136 KB
testcase_31 WA -
testcase_32 WA -
権限があれば一括ダウンロードができます

ソースコード

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 || check > N*N)
				break;
			for(auto &x : ok[check]){
				if(x.first == x.second)
					ans++;
				else
					ans += 2;
			}
		}

	cout << ans << endl;

	return 0;
}
0