結果

問題 No.800 四平方定理
ユーザー pockynypockyny
提出日時 2019-03-18 03:42:43
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
RE  
実行時間 -
コード長 319 bytes
コンパイル時間 491 ms
コンパイル使用メモリ 63,648 KB
実行使用メモリ 42,420 KB
最終ジャッジ日時 2023-09-22 18:56:09
合計ジャッジ時間 4,962 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 2 ms
4,684 KB
testcase_02 AC 3 ms
4,452 KB
testcase_03 AC 3 ms
4,392 KB
testcase_04 AC 2 ms
4,376 KB
testcase_05 AC 3 ms
4,380 KB
testcase_06 AC 3 ms
4,788 KB
testcase_07 AC 3 ms
4,408 KB
testcase_08 AC 3 ms
4,848 KB
testcase_09 AC 3 ms
4,572 KB
testcase_10 AC 35 ms
36,164 KB
testcase_11 AC 40 ms
38,164 KB
testcase_12 AC 41 ms
38,188 KB
testcase_13 AC 35 ms
36,104 KB
testcase_14 AC 38 ms
38,148 KB
testcase_15 AC 43 ms
38,164 KB
testcase_16 AC 38 ms
40,268 KB
testcase_17 AC 39 ms
40,532 KB
testcase_18 AC 44 ms
40,220 KB
testcase_19 AC 45 ms
40,380 KB
testcase_20 AC 1 ms
4,376 KB
testcase_21 AC 2 ms
4,376 KB
testcase_22 AC 43 ms
40,264 KB
testcase_23 RE -
testcase_24 RE -
testcase_25 RE -
testcase_26 AC 2 ms
4,376 KB
testcase_27 AC 2 ms
4,380 KB
testcase_28 RE -
testcase_29 RE -
testcase_30 RE -
testcase_31 RE -
testcase_32 RE -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>

using namespace std;
long long cnt[5000010] = {},n,d,ans = 0;
int main(){
	int i,j;
	cin >> n >> d;
	for(i=1;i<=n;i++){
		for(j=1;j<=n;j++){
			cnt[i*i+j*j]++;
		}
	}
	for(i=1;i<=n;i++){
		for(j=1;j<=n;j++){
			if(d - i*i + j*j<=0) continue;
			ans += cnt[d-i*i+j*j];
		}
	}
	cout << ans << endl;
}
0