結果
| 問題 | No.800 四平方定理 |
| コンテスト | |
| ユーザー |
vjudge1
|
| 提出日時 | 2026-03-11 10:56:33 |
| 言語 | C++23 (gcc 15.2.0 + boost 1.89.0) |
| 結果 |
AC
|
| 実行時間 | 64 ms / 2,000 ms |
| コード長 | 2,183 bytes |
| 記録 | |
| コンパイル時間 | 3,658 ms |
| コンパイル使用メモリ | 336,980 KB |
| 実行使用メモリ | 81,540 KB |
| 最終ジャッジ日時 | 2026-03-11 10:56:45 |
| 合計ジャッジ時間 | 4,703 ms |
|
ジャッジサーバーID (参考情報) |
judge3_0 / judge1_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 30 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
// Template
// ==============================================
// pbds
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>
// using namespace __gnu_pbds;
// template<typename T, typename comp = less<T>>
// using ordered_set = tree<T, null_type, comp, rb_tree_tag, tree_order_statistics_node_update>;
// Debugging
#ifdef LOCAL
#include "debug.h"
#else
#define debug(...)
#define see(x)
#endif
typedef long long ll;
typedef vector<int> VI;
typedef vector<long long> VLL;
typedef vector<bool> VB;
typedef vector<vector<int>> VVI;
typedef pair<int, int> PI;
typedef pair<ll, ll> PLL;
typedef vector<pair<int, int>> VPI;
#define pb push_back
#define ff first
#define ss second
#define mp make_pair
#define all(a) a.begin(), a.end()
#define revall(a) a.rbegin(), a.rend()
#define loop(i, s, e) for (int i = s; i < e; ++i)
#define inp(v) for (auto& x : v) cin >> x
#define outp(v, st) for (int i = st, n = v.size(); i < n; ++i) cout << v[i] << " \n"[i == n - 1]
#define nl "\n"
#define yep cout << "YES\n"
#define nope cout << "NO\n"
#define INF (int) 1e9
#define INFL (ll) 1e18
// #define MOD 998244353
#define MOD 1000000007
#define MAXN 10000002
// =============================================
void solve(int tc)
{
int n, d; cin >> n >> d;
int mxn = 2 * n * n + 1;
VI dp(mxn);
loop(i, 1, n + 1) loop(j, 1, n + 1) dp[i * i + j * j]++;
int offset = n * n;
VI dp2(mxn + offset);
loop(i, 1, n + 1) loop(j, 1, n + 1)
dp2[i * i - j * j + offset]++;
ll ans = 0;
loop(i, 1, mxn)
{
int x = d - i + offset;
if (x >= 0 && x < mxn + offset) ans += 1LL * dp[i] * dp2[x];
}
cout << ans << nl;
}
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);
int t = 1;
// cin >> t;
int x = t;
while(t--) solve(x - t);
#ifdef LOCAL
cerr << "Execution time: " << 1000.f * clock() / CLOCKS_PER_SEC << " ms." << nl;
#endif
return 0;
}
vjudge1