結果

問題 No.800 四平方定理
ユーザー misora192misora192
提出日時 2020-05-15 09:17:49
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 61 ms / 2,000 ms
コード長 699 bytes
コンパイル時間 1,782 ms
コンパイル使用メモリ 168,696 KB
実行使用メモリ 34,452 KB
最終ジャッジ日時 2023-10-17 18:12:17
合計ジャッジ時間 4,082 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,348 KB
testcase_01 AC 3 ms
4,348 KB
testcase_02 AC 2 ms
4,348 KB
testcase_03 AC 2 ms
4,348 KB
testcase_04 AC 2 ms
4,348 KB
testcase_05 AC 2 ms
4,348 KB
testcase_06 AC 3 ms
4,348 KB
testcase_07 AC 3 ms
4,348 KB
testcase_08 AC 3 ms
4,516 KB
testcase_09 AC 3 ms
4,348 KB
testcase_10 AC 23 ms
18,628 KB
testcase_11 AC 23 ms
20,672 KB
testcase_12 AC 23 ms
20,408 KB
testcase_13 AC 20 ms
19,352 KB
testcase_14 AC 23 ms
20,672 KB
testcase_15 AC 22 ms
20,408 KB
testcase_16 AC 24 ms
20,936 KB
testcase_17 AC 23 ms
20,936 KB
testcase_18 AC 25 ms
20,672 KB
testcase_19 AC 24 ms
20,672 KB
testcase_20 AC 2 ms
4,348 KB
testcase_21 AC 2 ms
4,348 KB
testcase_22 AC 26 ms
20,936 KB
testcase_23 AC 58 ms
34,452 KB
testcase_24 AC 58 ms
34,452 KB
testcase_25 AC 57 ms
34,452 KB
testcase_26 AC 2 ms
4,348 KB
testcase_27 AC 4 ms
7,088 KB
testcase_28 AC 59 ms
34,452 KB
testcase_29 AC 54 ms
34,452 KB
testcase_30 AC 60 ms
34,452 KB
testcase_31 AC 45 ms
32,144 KB
testcase_32 AC 61 ms
34,452 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#define rep(i,n) for(int i=(0);i<(n);i++)

using namespace std;

typedef long long ll;

template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);

	int n, d;
	cin >> n >> d;

	int max_n = max((n + 1) * (n + 1) + d, 2 * (n + 1) * (n + 1)) + 1;
	vector<int> v(max_n, 0);

	rep(z, n) rep(w, n){
		int a = (w + 1) * (w + 1) - (z + 1) * (z + 1) + d;
		if(a >= 0) v[a]++;
	}

	int ans = 0;
	rep(x, n) rep(y, n){
		int a = (x + 1) * (x + 1) + (y + 1) * (y + 1);
		ans += v[a];
	}

	cout << ans << endl;
}
0