結果
| 問題 | No.800 四平方定理 |
| コンテスト | |
| ユーザー |
sten_san
|
| 提出日時 | 2021-02-13 12:19:25 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.89.0) |
| 結果 |
AC
|
| 実行時間 | 96 ms / 2,000 ms |
| コード長 | 879 bytes |
| 記録 | |
| コンパイル時間 | 2,503 ms |
| コンパイル使用メモリ | 191,376 KB |
| 最終ジャッジ日時 | 2025-01-18 20:05:54 |
|
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 30 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
struct uns_t {} uns;
template <typename Element, typename Head, typename ...Args>
auto vec(Element init, Head arg, Args ...args) {
if constexpr (sizeof...(Args) == 0) return std::vector(arg, init);
else return std::vector(arg, vec(init, args...));
}
template <typename Element, typename Head, typename ...Args>
auto vec(uns_t, Head arg, Args ...args) {
return vec(Element(), arg, args...);
}
array<int, 10000000> cnt;
int main() {
int n, d; cin >> n >> d;
for (int i = 1; i <= n; ++i) {
for (int j = 1; j <= n; ++j) {
if (i * i - j * j + d < 0) continue;
++cnt[i * i - j * j + d];
}
}
int64_t ans = 0;
for (int i = 1; i <= n; ++i) {
for (int j = 1; j <= n; ++j) {
ans += cnt[i * i + j * j];
}
}
cout << ans << endl;
}
sten_san