結果
問題 |
No.800 四平方定理
|
ユーザー |
![]() |
提出日時 | 2020-08-24 22:42:34 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
TLE
|
実行時間 | - |
コード長 | 672 bytes |
コンパイル時間 | 1,646 ms |
コンパイル使用メモリ | 174,968 KB |
実行使用メモリ | 148,480 KB |
最終ジャッジ日時 | 2024-11-06 10:50:52 |
合計ジャッジ時間 | 8,999 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | -- * 3 |
other | AC * 10 TLE * 5 -- * 15 |
ソースコード
#include<bits/stdc++.h> #define rep(i,N) for(ll (i)=0;(i)<(N);(i)++) #define chmax(x,y) x=max(x,y) #define chmin(x,y) x=min(x,y) using namespace std; typedef long long ll; typedef pair<int,int> P; const int mod = 1000000007; const int INF = 1001001001; int main() { int n, d; cin >> n >> d; map<ll, int> a, b; for (ll i = 1; i <= n; ++i) for(ll j = 1; j <= n; ++j) { ll v = i*i + j*j; a[v]++; } for (ll i = 1; i <= n; ++i) for(ll j = 1; j <= n; ++j) { ll v = i*i - j*j; b[v]++; } ll ans = 0; for (auto ita = a.begin(); ita != a.end(); ita++) { int v = (*ita).first - d; ans += b[v] * (*ita).second; } cout << ans << endl; }