結果
問題 |
No.800 四平方定理
|
ユーザー |
![]() |
提出日時 | 2019-03-17 22:34:40 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
TLE
|
実行時間 | - |
コード長 | 757 bytes |
コンパイル時間 | 1,490 ms |
コンパイル使用メモリ | 173,712 KB |
実行使用メモリ | 65,408 KB |
最終ジャッジ日時 | 2024-07-08 00:41:22 |
合計ジャッジ時間 | 13,609 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 26 TLE * 4 |
ソースコード
#include <bits/stdc++.h> using namespace std; typedef long long int ll; ll MOD = 1000000007; ll INFL = 1ll << 60; ll INF = 1 << 30; #define CONTAINS(v, x) (v.find(x) != v.end()) // =============================================================================== int main() { ll n, d; cin >> n >> d; map<ll, int> right; //(w+z)(w-z)+D for (int w = 1; w <= n; w++) { for (int z = 1; z <= n; z++) { int r = w * w - z * z + d; right[r]++; if (r <= 0) break; } } ll ans = 0; // x^2+y^2 for (int x = 1; x <= n; x++) { for (int y = x; y <= n; y++) { ll l = x * x + y * y; if (CONTAINS(right, l)) { ans += right.find(l)->second * ((x == y) ? 1 : 2); } } } cout << ans << endl; }