結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 2 ms
4,644 KB
testcase_02 AC 3 ms
4,492 KB
testcase_03 AC 2 ms
4,376 KB
testcase_04 AC 2 ms
4,376 KB
testcase_05 AC 2 ms
4,380 KB
testcase_06 AC 3 ms
4,700 KB
testcase_07 AC 2 ms
4,376 KB
testcase_08 AC 3 ms
4,964 KB
testcase_09 AC 2 ms
4,584 KB
testcase_10 AC 37 ms
36,152 KB
testcase_11 AC 41 ms
38,204 KB
testcase_12 AC 42 ms
38,144 KB
testcase_13 AC 38 ms
36,164 KB
testcase_14 AC 39 ms
38,160 KB
testcase_15 AC 41 ms
38,144 KB
testcase_16 AC 41 ms
40,336 KB
testcase_17 AC 39 ms
40,164 KB
testcase_18 AC 43 ms
40,236 KB
testcase_19 AC 44 ms
40,300 KB
testcase_20 AC 1 ms
4,376 KB
testcase_21 AC 1 ms
4,376 KB
testcase_22 AC 43 ms
40,248 KB
testcase_23 RE -
testcase_24 RE -
testcase_25 RE -
testcase_26 AC 2 ms
4,376 KB
testcase_27 AC 1 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