結果

問題 No.800 四平方定理
ユーザー eto_nagisaeto_nagisa
提出日時 2019-03-18 04:14:29
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
TLE  
実行時間 -
コード長 1,124 bytes
コンパイル時間 1,539 ms
コンパイル使用メモリ 170,908 KB
実行使用メモリ 117,304 KB
最終ジャッジ日時 2023-09-22 20:11:19
合計ジャッジ時間 5,645 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 20 ms
6,296 KB
testcase_01 AC 40 ms
8,984 KB
testcase_02 AC 26 ms
7,156 KB
testcase_03 AC 31 ms
7,936 KB
testcase_04 AC 25 ms
7,004 KB
testcase_05 AC 30 ms
7,560 KB
testcase_06 AC 50 ms
9,972 KB
testcase_07 AC 38 ms
8,316 KB
testcase_08 AC 54 ms
10,164 KB
testcase_09 AC 44 ms
8,984 KB
testcase_10 TLE -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
testcase_31 -- -
testcase_32 -- -
権限があれば一括ダウンロードができます

ソースコード

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;
	map<ll, ll> a, b;
	REP(i, n)REP(j, n) {
		ll x = i + 1, y = j + 1;
		a[x*x + y * y]++;
		b[x*x - y * y]++;
	}
	ll ans = 0;
	for (auto c : a) {
		ans += c.second*b[c.first - d];
	}
	cout << ans << endl;
}
0