結果

問題 No.800 四平方定理
ユーザー eto_nagisaeto_nagisa
提出日時 2019-03-18 04:25:31
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 264 ms / 2,000 ms
コード長 1,162 bytes
コンパイル時間 1,477 ms
コンパイル使用メモリ 165,944 KB
実行使用メモリ 190,640 KB
最終ジャッジ日時 2023-09-22 20:30:38
合計ジャッジ時間 6,225 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 3 ms
4,848 KB
testcase_01 AC 5 ms
6,392 KB
testcase_02 AC 4 ms
5,356 KB
testcase_03 AC 4 ms
5,888 KB
testcase_04 AC 4 ms
5,376 KB
testcase_05 AC 4 ms
5,644 KB
testcase_06 AC 5 ms
7,184 KB
testcase_07 AC 5 ms
6,696 KB
testcase_08 AC 7 ms
10,140 KB
testcase_09 AC 5 ms
6,824 KB
testcase_10 AC 89 ms
95,800 KB
testcase_11 AC 123 ms
107,352 KB
testcase_12 AC 106 ms
105,408 KB
testcase_13 AC 96 ms
100,364 KB
testcase_14 AC 105 ms
107,408 KB
testcase_15 AC 105 ms
106,828 KB
testcase_16 AC 108 ms
108,668 KB
testcase_17 AC 110 ms
108,464 KB
testcase_18 AC 111 ms
108,128 KB
testcase_19 AC 109 ms
108,412 KB
testcase_20 AC 2 ms
4,376 KB
testcase_21 AC 1 ms
4,380 KB
testcase_22 AC 109 ms
108,504 KB
testcase_23 AC 241 ms
190,500 KB
testcase_24 AC 264 ms
190,500 KB
testcase_25 AC 238 ms
189,968 KB
testcase_26 AC 1 ms
4,380 KB
testcase_27 AC 9 ms
18,772 KB
testcase_28 AC 241 ms
189,708 KB
testcase_29 AC 245 ms
190,336 KB
testcase_30 AC 242 ms
189,712 KB
testcase_31 AC 219 ms
176,908 KB
testcase_32 AC 239 ms
190,640 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include "bits/stdc++.h"

#define REP(i,n) for(ll i=0;i<ll(n);++i)
#define RREP(i,n) for(ll i=ll(n)-1;i>=0;--i)
#define FOR(i,m,n) for(ll i=m;i<ll(n);++i)
#define RFOR(i,m,n) for(ll i=ll(n)-1;i>=ll(m);--i)
#define ALL(v) (v).begin(),(v).end()
#define UNIQUE(v) v.erase(unique(ALL(v)),v.end());
#define INF 1000000001ll
#define MOD 1000000007ll
#define EPS 1e-9

constexpr int dx[8] = { 1,1,0,-1,-1,-1,0,1 };
constexpr int dy[8] = { 0,1,1,1,0,-1,-1,-1 };


using namespace std;

using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector<vi>;
using vvl = vector<vl>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

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

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll n, d; cin >> n >> d;
	int sz = max(n*n, d) + 2 * n * n + 1;
	vl a(sz, 0), b(sz, 0);
	REP(i, n)REP(j, n) {
		ll x = i + 1, y = j + 1;
		a[x*x + y * y + n * n]++;
		b[x*x - y * y + d + n * n]++;
	}
	ll ans = 0;
	REP(i, sz)ans += a[i] * b[i];
	cout << ans << endl;
}
0