結果

問題 No.800 四平方定理
ユーザー leaf_1415leaf_1415
提出日時 2019-03-17 21:28:24
言語 C++11
(gcc 8.5.0)
結果
AC  
実行時間 1,422 ms / 2,000 ms
コード長 532 bytes
コンパイル時間 1,211 ms
使用メモリ 37,040 KB
最終ジャッジ日時 2023-02-11 04:11:56
合計ジャッジ時間 20,239 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
使用メモリ
testcase_00 AC 10 ms
6,952 KB
testcase_01 AC 19 ms
6,948 KB
testcase_02 AC 14 ms
4,900 KB
testcase_03 AC 15 ms
4,904 KB
testcase_04 AC 14 ms
6,948 KB
testcase_05 AC 15 ms
4,904 KB
testcase_06 AC 22 ms
4,904 KB
testcase_07 AC 16 ms
4,900 KB
testcase_08 AC 12 ms
4,904 KB
testcase_09 AC 19 ms
4,900 KB
testcase_10 AC 673 ms
19,912 KB
testcase_11 AC 709 ms
35,980 KB
testcase_12 AC 752 ms
37,020 KB
testcase_13 AC 612 ms
19,568 KB
testcase_14 AC 662 ms
36,540 KB
testcase_15 AC 755 ms
36,472 KB
testcase_16 AC 669 ms
36,568 KB
testcase_17 AC 667 ms
37,040 KB
testcase_18 AC 814 ms
36,628 KB
testcase_19 AC 816 ms
36,940 KB
testcase_20 AC 2 ms
4,900 KB
testcase_21 AC 2 ms
4,904 KB
testcase_22 AC 818 ms
36,068 KB
testcase_23 AC 1,422 ms
35,988 KB
testcase_24 AC 1,232 ms
36,108 KB
testcase_25 AC 1,414 ms
36,664 KB
testcase_26 AC 1 ms
4,904 KB
testcase_27 AC 1 ms
4,900 KB
testcase_28 AC 1,224 ms
35,956 KB
testcase_29 AC 1,335 ms
36,124 KB
testcase_30 AC 1,226 ms
36,504 KB
testcase_31 AC 1,137 ms
36,396 KB
testcase_32 AC 1,262 ms
35,956 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

using namespace std;

llint n, d;
vector<llint> vec;

int main(void)
{
	cin >> n >> d;
	
	for(int i = 1; i <= n; i++){
		for(int j = 1; j <= n; j++){
			vec.push_back(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++){
			ans += upper_bound(vec.begin(), vec.end(), d-(i*i+j*j)) - lower_bound(vec.begin(), vec.end(), d-(i*i+j*j));
		}
	}
	cout << ans << endl;
	
	return 0;
}
0