結果

問題 No.800 四平方定理
ユーザー leaf_1415leaf_1415
提出日時 2019-03-17 21:32:40
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 108 ms / 2,000 ms
コード長 486 bytes
コンパイル時間 466 ms
コンパイル使用メモリ 60,020 KB
実行使用メモリ 66,928 KB
最終ジャッジ日時 2023-09-22 04:03:00
合計ジャッジ時間 3,223 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 3 ms
4,380 KB
testcase_01 AC 2 ms
4,512 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 AC 3 ms
4,380 KB
testcase_04 AC 3 ms
4,380 KB
testcase_05 AC 3 ms
4,380 KB
testcase_06 AC 4 ms
4,688 KB
testcase_07 AC 3 ms
4,424 KB
testcase_08 AC 4 ms
4,676 KB
testcase_09 AC 3 ms
4,508 KB
testcase_10 AC 44 ms
36,180 KB
testcase_11 AC 47 ms
38,180 KB
testcase_12 AC 49 ms
38,104 KB
testcase_13 AC 42 ms
36,160 KB
testcase_14 AC 46 ms
38,088 KB
testcase_15 AC 48 ms
38,112 KB
testcase_16 AC 46 ms
40,168 KB
testcase_17 AC 49 ms
40,244 KB
testcase_18 AC 55 ms
40,356 KB
testcase_19 AC 53 ms
40,164 KB
testcase_20 AC 1 ms
4,376 KB
testcase_21 AC 2 ms
4,376 KB
testcase_22 AC 56 ms
40,128 KB
testcase_23 AC 104 ms
66,868 KB
testcase_24 AC 97 ms
66,788 KB
testcase_25 AC 108 ms
66,928 KB
testcase_26 AC 2 ms
4,380 KB
testcase_27 AC 2 ms
4,376 KB
testcase_28 AC 97 ms
66,880 KB
testcase_29 AC 100 ms
66,852 KB
testcase_30 AC 95 ms
66,756 KB
testcase_31 AC 89 ms
62,720 KB
testcase_32 AC 98 ms
66,792 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <vector>
#include <algorithm>
#define llint long long

using namespace std;

llint n, d;
llint cnt[16000005];

int main(void)
{
	cin >> n >> d;
	
	for(int i = 1; i <= n; i++){
		for(int j = 1; j <= n; j++){
			cnt[i*i+j*j]++;
		}
	}
	//sort(vec.begin(), vec.end());
	
	llint ans = 0;
	for(int i = 1; i <= n; i++){
		for(int j = 1; j <= n; j++){
			llint x = d - (i*i-j*j);
			if(x < 0) continue;
			ans += cnt[x];
		}
	}
	cout << ans << endl;
	
	return 0;
}
0