結果
問題 | No.800 四平方定理 |
ユーザー |
|
提出日時 | 2019-03-18 00:46:12 |
言語 | C++11 (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 131 ms / 2,000 ms |
コード長 | 560 bytes |
コンパイル時間 | 1,206 ms |
コンパイル使用メモリ | 159,444 KB |
実行使用メモリ | 73,472 KB |
最終ジャッジ日時 | 2024-07-08 07:49:55 |
合計ジャッジ時間 | 3,637 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 30 |
ソースコード
#include <bits/stdc++.h>using namespace std;int main(int argc, char *argv[]) {int N, D;cin >> N >> D;vector<int64_t> arr(N * N + N * N + D, 0);for (int x = 1; x <= N; x++) {for (int y = 1; y <= N; y++) {arr[x * x + y * y]++;}}int64_t ans = 0;for (int w = 1; w <= N; w++) {for (int z = 1; z <= N; z++) {int one = w * w - z * z + D;if (one >= 0) {ans += arr[one];}}}cout << ans << endl;return 0;}