結果
| 問題 | No.800 四平方定理 |
| コンテスト | |
| ユーザー |
vjudge1
|
| 提出日時 | 2026-03-10 18:56:02 |
| 言語 | C++23 (gcc 15.2.0 + boost 1.89.0) |
| 結果 |
AC
|
| 実行時間 | 51 ms / 2,000 ms |
| コード長 | 890 bytes |
| 記録 | |
| コンパイル時間 | 2,093 ms |
| コンパイル使用メモリ | 336,180 KB |
| 実行使用メモリ | 65,904 KB |
| 最終ジャッジ日時 | 2026-03-10 18:56:06 |
| 合計ジャッジ時間 | 3,628 ms |
|
ジャッジサーバーID (参考情報) |
judge3_0 / judge2_1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 30 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
#define nl "\n"
#define int long long
#define yes cout << "YES" << nl;
#define no cout << "NO" << nl;
#define vi vector<int>
#define ip(x) for(auto &it : x) cin >> it
#define all(x) x.begin(),x.end()
// - Mohammad Hasibur Rahman
void solve() {
int n, d; cin >> n >> d;
int mx = 2 * n * n;
vi v(mx + 1, 0);
for (int x = 1; x <= n; x++) {
for (int y = 1; y <= n; y++) {
v[x*x + y*y]++;
}
}
int ans = 0;
for (int w = 1; w <= n; w++) {
int target = w * w + d;
for (int z = 1; z <= n; z++) {
int rem = target - z * z;
if (rem >= 2 && rem <= mx) {
ans += v[rem];
}
}
}
cout << ans << nl;
}
signed main() {
ios::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
solve();
}
vjudge1