結果

問題 No.800 四平方定理
ユーザー pockynypockyny
提出日時 2019-03-18 03:43:56
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 86 ms / 2,000 ms
コード長 320 bytes
コンパイル時間 505 ms
コンパイル使用メモリ 65,152 KB
実行使用メモリ 66,868 KB
最終ジャッジ日時 2023-09-22 18:59:50
合計ジャッジ時間 2,799 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 3 ms
4,520 KB
testcase_02 AC 2 ms
4,376 KB
testcase_03 AC 2 ms
4,376 KB
testcase_04 AC 2 ms
4,376 KB
testcase_05 AC 2 ms
4,376 KB
testcase_06 AC 3 ms
4,756 KB
testcase_07 AC 2 ms
4,560 KB
testcase_08 AC 3 ms
4,728 KB
testcase_09 AC 2 ms
4,600 KB
testcase_10 AC 39 ms
36,120 KB
testcase_11 AC 39 ms
38,192 KB
testcase_12 AC 38 ms
38,136 KB
testcase_13 AC 33 ms
36,152 KB
testcase_14 AC 36 ms
38,192 KB
testcase_15 AC 40 ms
38,168 KB
testcase_16 AC 38 ms
40,180 KB
testcase_17 AC 36 ms
40,192 KB
testcase_18 AC 39 ms
40,364 KB
testcase_19 AC 41 ms
40,376 KB
testcase_20 AC 1 ms
4,380 KB
testcase_21 AC 1 ms
4,380 KB
testcase_22 AC 41 ms
40,364 KB
testcase_23 AC 84 ms
66,844 KB
testcase_24 AC 79 ms
66,812 KB
testcase_25 AC 85 ms
66,824 KB
testcase_26 AC 2 ms
4,376 KB
testcase_27 AC 2 ms
4,376 KB
testcase_28 AC 75 ms
66,868 KB
testcase_29 AC 86 ms
66,816 KB
testcase_30 AC 82 ms
66,864 KB
testcase_31 AC 73 ms
62,720 KB
testcase_32 AC 81 ms
66,804 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>

using namespace std;
long long cnt[10000000] = {},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