結果

問題 No.800 四平方定理
ユーザー LaFolia13LaFolia13
提出日時 2019-03-17 23:31:42
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 678 bytes
コンパイル時間 1,498 ms
コンパイル使用メモリ 170,192 KB
実行使用メモリ 240,932 KB
最終ジャッジ日時 2023-09-22 13:56:32
合計ジャッジ時間 11,009 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 5 ms
5,344 KB
testcase_01 AC 7 ms
7,496 KB
testcase_02 AC 6 ms
6,204 KB
testcase_03 AC 6 ms
6,724 KB
testcase_04 AC 6 ms
5,952 KB
testcase_05 AC 6 ms
6,340 KB
testcase_06 AC 9 ms
8,480 KB
testcase_07 WA -
testcase_08 WA -
testcase_09 AC 7 ms
7,720 KB
testcase_10 AC 285 ms
120,888 KB
testcase_11 AC 309 ms
135,672 KB
testcase_12 AC 311 ms
133,248 KB
testcase_13 AC 290 ms
126,440 KB
testcase_14 AC 303 ms
135,540 KB
testcase_15 AC 318 ms
134,612 KB
testcase_16 AC 311 ms
137,152 KB
testcase_17 AC 315 ms
136,932 KB
testcase_18 AC 323 ms
136,516 KB
testcase_19 AC 320 ms
136,592 KB
testcase_20 AC 2 ms
4,376 KB
testcase_21 WA -
testcase_22 AC 336 ms
136,964 KB
testcase_23 AC 642 ms
240,776 KB
testcase_24 AC 595 ms
240,932 KB
testcase_25 AC 612 ms
240,140 KB
testcase_26 AC 2 ms
4,380 KB
testcase_27 AC 2 ms
4,380 KB
testcase_28 AC 587 ms
239,740 KB
testcase_29 AC 591 ms
240,376 KB
testcase_30 AC 593 ms
240,136 KB
testcase_31 AC 538 ms
223,532 KB
testcase_32 AC 587 ms
240,868 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 || check > N*N*2)
				break;
			for(auto &x : ok[check]){
				if(x.first == x.second)
					ans++;
				else
					ans += 2;
			}
		}

	cout << ans << endl;

	return 0;
}
0