結果

問題 No.800 四平方定理
ユーザー minamiminami
提出日時 2019-03-17 21:36:41
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 112 ms / 2,000 ms
コード長 935 bytes
コンパイル時間 1,563 ms
コンパイル使用メモリ 166,632 KB
実行使用メモリ 65,744 KB
最終ジャッジ日時 2023-09-22 04:14:09
合計ジャッジ時間 4,515 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 3 ms
4,380 KB
testcase_01 AC 3 ms
4,376 KB
testcase_02 AC 2 ms
4,376 KB
testcase_03 AC 2 ms
4,380 KB
testcase_04 AC 2 ms
4,376 KB
testcase_05 AC 2 ms
4,380 KB
testcase_06 AC 3 ms
4,428 KB
testcase_07 AC 3 ms
4,376 KB
testcase_08 AC 3 ms
4,380 KB
testcase_09 AC 3 ms
4,376 KB
testcase_10 AC 44 ms
34,040 KB
testcase_11 AC 50 ms
37,832 KB
testcase_12 AC 49 ms
37,416 KB
testcase_13 AC 44 ms
35,420 KB
testcase_14 AC 49 ms
37,876 KB
testcase_15 AC 53 ms
37,572 KB
testcase_16 AC 46 ms
38,036 KB
testcase_17 AC 49 ms
38,188 KB
testcase_18 AC 55 ms
38,060 KB
testcase_19 AC 55 ms
38,060 KB
testcase_20 AC 1 ms
4,376 KB
testcase_21 AC 1 ms
4,376 KB
testcase_22 AC 53 ms
38,036 KB
testcase_23 AC 111 ms
65,688 KB
testcase_24 AC 101 ms
65,744 KB
testcase_25 AC 112 ms
65,420 KB
testcase_26 AC 2 ms
4,384 KB
testcase_27 AC 2 ms
4,376 KB
testcase_28 AC 98 ms
65,152 KB
testcase_29 AC 107 ms
65,548 KB
testcase_30 AC 96 ms
65,220 KB
testcase_31 AC 90 ms
60,780 KB
testcase_32 AC 102 ms
65,364 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include "bits/stdc++.h"
using namespace std;
#ifdef _DEBUG
#include "dump.hpp"
#else
#define dump(...)
#endif

#define int long long
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)
const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = 1'000'000'007;
template<class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (b < a) { a = b; return true; } return false; }

signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int N, D; cin >> N >> D;
	vector<int> v(2 * N*N + 1);

	rep(x, 1, N + 1)rep(y, 1, N + 1) {
		v[x*x + y * y]++;
	}
	int ans = 0;
	rep(z, 1, N + 1)rep(w, 1, N + 1) {
		int r = w * w - z * z + D;
		if (r < 0 || r >= 2 * N * N + 1)continue;
		if (v[r])
			ans+=v[r];
	}
	cout << ans << endl;
	return 0;
}
0