結果
問題 | No.800 四平方定理 |
ユーザー |
![]() |
提出日時 | 2019-03-17 23:01:27 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 578 bytes |
コンパイル時間 | 525 ms |
コンパイル使用メモリ | 68,352 KB |
実行使用メモリ | 65,792 KB |
最終ジャッジ日時 | 2024-07-08 01:42:58 |
合計ジャッジ時間 | 3,596 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 27 WA * 2 RE * 1 |
ソースコード
#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 (val >= 0) ans += cnt[val]; } } cout << ans << endl; return 0; }