結果
| 問題 |
No.800 四平方定理
|
| コンテスト | |
| ユーザー |
kcvlex
|
| 提出日時 | 2019-03-17 21:29:14 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
RE
|
| 実行時間 | - |
| コード長 | 2,539 bytes |
| コンパイル時間 | 1,490 ms |
| コンパイル使用メモリ | 158,272 KB |
| 実行使用メモリ | 42,112 KB |
| 最終ジャッジ日時 | 2024-07-07 20:34:22 |
| 合計ジャッジ時間 | 5,127 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 22 RE * 8 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
#define DEBUG_MODE
#define endl '\n'
#ifdef DEBUG_MODE
#define DEBUG(X) debug_func(X, #X)
#define DEBUG_ENDL endl << flush
#define DEBUG_SEPARATOR_LINE cout<<"=================\n"
#else
#define DEBUG(X) 0
#define DEBUG_ENDL 0
#define DEBUG_SEPARATOR_LINE 0
#endif
#define ALL(V) (V).begin(), (V).end()
#define ALLR(V) (V).rbegin(), (V).rend()
#define DEBUG_ENDL_S(S) ((S).size() ? "\n" : "") << flush;
template <typename T> using V = vector<T>;
template <typename T> using VV = V<V<T>>;
template <typename T, typename U> using P = pair<T, U>;
using ll = int64_t;
using PLL = P<ll, ll>;
template <typename T> const T& var_min(const T &t) { return t; }
template <typename T> const T& var_max(const T &t) { return t; }
template <typename Head, typename... Tail> const Head& var_min(const Head &head, const Tail&... tail) { return min(head, var_min(tail...)); }
template <typename Head, typename... Tail> const Head& var_max(const Head &head, const Tail&... tail) { return max(head, var_max(tail...)); }
template <typename T, typename... Tail> void chmin(T &t, const Tail&... tail) { t = var_min(t, tail...); }
template <typename T, typename... Tail> void chmax(T &t, const Tail&... tail) { t = var_max(t, tail...); }
void debug_func_preffix(const string &s) { if(s.size()) cout << s << " = "; }
template <typename T>
void debug_func(const T &t, const string &s = "") {
debug_func_preffix(s);
cout << t << DEBUG_ENDL_S(s);
}
template <typename T, typename U>
void debug_func(const P<T, U> &p, const string &s = "") {
debug_func_preffix(s);
cout << "(";
debug_func(p.first);
cout << ", ";
debug_func(p.second);
cout << ")" << DEBUG_ENDL_S(s);
}
template <typename T>
void debug_func(const V<T> &v, const string &s = "") {
for(ll i = 0; i < v.size(); i++) {
string t = s + "[" + to_string(i) + "]";
debug_func(v[i], t);
}
}
void init_io() {
cin.tie(0);
ios_base::sync_with_stdio(false);
cout << fixed << setprecision(30);
}
const ll maxs = (ll)5e6 + 10;
ll cnt[maxs];
int main() {
init_io();
ll N, D;
cin >> N >> D;
for(ll y = 1; y <= N; y++) {
for(ll z = 1; z <= N; z++) {
cnt[y * y + z * z]++;
}
}
ll ans = 0;
for(ll x = 1; x <= N; x++) {
for(ll w = 1; w <= N; w++) {
ll rv = w * w - x * x + D;
if(rv < 0) continue;
if(rv >= maxs) continue;
ans += cnt[rv];
}
}
cout << ans << endl;
return 0;
}
kcvlex