結果
問題 | No.800 四平方定理 |
ユーザー |
![]() |
提出日時 | 2019-03-17 23:02:31 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 95 ms / 2,000 ms |
コード長 | 598 bytes |
コンパイル時間 | 590 ms |
コンパイル使用メモリ | 69,964 KB |
実行使用メモリ | 65,796 KB |
最終ジャッジ日時 | 2024-07-08 01:44:29 |
合計ジャッジ時間 | 2,942 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 30 |
ソースコード
#include <iostream>#include <vector>using namespace std;using ll = long long;template <class T>inline T sq(T a) { return a * a; }int main() {int N, D;cin >> N >> D;vector<ll> cnt(sq(N) * 2 + 1, 0);for (int x = 1; x <= N; ++x) {for (int y = 1; y <= N; ++y) {++cnt[sq(x) + sq(y)];}}ll ans = 0;for (int z = 1; z <= N; ++z) {for (int w = 1; w <= N; ++w) {int val = sq(w) - sq(z) + D;if (0 <= val && val <= sq(N) * 2) ans += cnt[val];}}cout << ans << endl;return 0;}