結果

問題 No.800 四平方定理
ユーザー furafura
提出日時 2020-05-13 06:52:32
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 64 ms / 2,000 ms
コード長 382 bytes
コンパイル時間 2,170 ms
コンパイル使用メモリ 199,516 KB
実行使用メモリ 34,504 KB
最終ジャッジ日時 2023-10-12 15:17:13
合計ジャッジ時間 4,486 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,352 KB
testcase_01 AC 2 ms
4,352 KB
testcase_02 AC 2 ms
4,352 KB
testcase_03 AC 2 ms
4,348 KB
testcase_04 AC 2 ms
4,352 KB
testcase_05 AC 2 ms
4,352 KB
testcase_06 AC 2 ms
4,352 KB
testcase_07 AC 2 ms
4,352 KB
testcase_08 AC 2 ms
4,348 KB
testcase_09 AC 2 ms
4,348 KB
testcase_10 AC 21 ms
18,452 KB
testcase_11 AC 24 ms
20,528 KB
testcase_12 AC 22 ms
20,204 KB
testcase_13 AC 19 ms
19,184 KB
testcase_14 AC 22 ms
20,532 KB
testcase_15 AC 22 ms
20,528 KB
testcase_16 AC 23 ms
20,520 KB
testcase_17 AC 24 ms
20,696 KB
testcase_18 AC 26 ms
20,432 KB
testcase_19 AC 25 ms
20,436 KB
testcase_20 AC 2 ms
4,348 KB
testcase_21 AC 2 ms
4,352 KB
testcase_22 AC 25 ms
20,540 KB
testcase_23 AC 64 ms
34,300 KB
testcase_24 AC 61 ms
34,504 KB
testcase_25 AC 63 ms
34,292 KB
testcase_26 AC 2 ms
4,352 KB
testcase_27 AC 2 ms
4,352 KB
testcase_28 AC 61 ms
34,044 KB
testcase_29 AC 63 ms
34,376 KB
testcase_30 AC 61 ms
34,020 KB
testcase_31 AC 54 ms
31,972 KB
testcase_32 AC 60 ms
34,256 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>

#define rep(i,n) for(int i=0;i<(n);i++)

using namespace std;

int main(){
	int n,d; scanf("%d%d",&n,&d);

	vector<int> cnt(2*n*n+1);
	for(int x=1;x<=n;x++) for(int y=1;y<=n;y++) cnt[x*x+y*y]++;

	int ans=0;
	for(int z=1;z<=n;z++) for(int w=1;w<=n;w++) {
		int tar=w*w+d-z*z;
		if(0<=tar && tar<=2*n*n) ans+=cnt[tar];
	}
	printf("%d\n",ans);

	return 0;
}
0