結果
問題 | No.800 四平方定理 |
ユーザー |
|
提出日時 | 2019-05-01 23:00:40 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 64 ms / 2,000 ms |
コード長 | 542 bytes |
コンパイル時間 | 1,828 ms |
コンパイル使用メモリ | 169,112 KB |
実行使用メモリ | 38,444 KB |
最終ジャッジ日時 | 2024-12-31 12:43:16 |
合計ジャッジ時間 | 3,658 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 30 |
ソースコード
#include <bits/stdc++.h> using namespace std; int main(){ cin.tie(0); ios::sync_with_stdio(false); int N, D; cin >> N >> D; vector<int> freq(2 * N * N + 1 + D, 0); for (int x = 1; x <= N; ++x){ for (int y = 1; y <= N; ++y){ ++freq[x*x + y*y]; } } long long ans = 0; for (int z = 1; z <= N; ++z){ for (int w = 1; w <= N; ++w){ int tmp = w * w + D - z * z; if (tmp > 0) ans += freq[tmp]; } } cout << ans << endl; return 0; }