結果
問題 | No.800 四平方定理 |
ユーザー |
![]() |
提出日時 | 2019-03-18 04:14:29 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
TLE
|
実行時間 | - |
コード長 | 1,124 bytes |
コンパイル時間 | 1,539 ms |
コンパイル使用メモリ | 173,140 KB |
実行使用メモリ | 151,424 KB |
最終ジャッジ日時 | 2024-07-08 10:53:17 |
合計ジャッジ時間 | 8,471 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 TLE * 1 |
other | AC * 10 TLE * 11 -- * 9 |
ソースコード
#include "bits/stdc++.h" #define REP(i,n) for(ll i=0;i<ll(n);++i) #define RREP(i,n) for(ll i=ll(n)-1;i>=0;--i) #define FOR(i,m,n) for(ll i=m;i<ll(n);++i) #define RFOR(i,m,n) for(ll i=ll(n)-1;i>=ll(m);--i) #define ALL(v) (v).begin(),(v).end() #define UNIQUE(v) v.erase(unique(ALL(v)),v.end()); #define INF 1000000001ll #define MOD 1000000007ll #define EPS 1e-9 constexpr int dx[8] = { 1,1,0,-1,-1,-1,0,1 }; constexpr int dy[8] = { 0,1,1,1,0,-1,-1,-1 }; using namespace std; using ll = long long; using vi = vector<int>; using vl = vector<ll>; using vvi = vector<vi>; using vvl = vector<vl>; using pii = pair<int, int>; using pll = pair<ll, ll>; template <class T> bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; } template <class T> bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; } int main() { cin.tie(0); ios::sync_with_stdio(false); ll n, d; cin >> n >> d; map<ll, ll> a, b; REP(i, n)REP(j, n) { ll x = i + 1, y = j + 1; a[x*x + y * y]++; b[x*x - y * y]++; } ll ans = 0; for (auto c : a) { ans += c.second*b[c.first - d]; } cout << ans << endl; }