結果
問題 |
No.800 四平方定理
|
ユーザー |
|
提出日時 | 2019-03-17 22:19:11 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
TLE
|
実行時間 | - |
コード長 | 538 bytes |
コンパイル時間 | 1,823 ms |
コンパイル使用メモリ | 201,532 KB |
最終ジャッジ日時 | 2025-01-06 23:06:57 |
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 22 TLE * 8 |
ソースコード
#define _USE_MATH_DEFINES #include <bits/stdc++.h> using namespace std; signed main() { ios::sync_with_stdio(false); cin.tie(0); int n, d; cin >> n >> d; map<int, int> mp; for (int x = 1; x <= n; x++) { for (int y = 1; y <= n; y++) { mp[x * x + y * y]++; } } int ans = 0; for (int w = 1; w <= n; w++) { for (int z = 1; z <= n; z++) { int res = d + w * w - z * z; if (res < 2) continue; if (mp.count(res)) { ans += mp[res]; } } } cout << ans << endl; return 0; }