結果
問題 | No.800 四平方定理 |
ユーザー |
|
提出日時 | 2019-03-17 22:47:48 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 1,080 ms / 2,000 ms |
コード長 | 1,357 bytes |
コンパイル時間 | 1,945 ms |
コンパイル使用メモリ | 199,136 KB |
最終ジャッジ日時 | 2025-01-06 23:12:08 |
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 30 |
ソースコード
#include "bits/stdc++.h" using namespace std; using ll = long long; using ull = unsigned long long; //#define int ll using vb = vector<bool>; using vvb = vector<vb>; using vi = vector<int>; using vvi = vector<vi>; using vl = vector<ll>; using vvl = vector<vl>; template<class T> using V = vector<T>; template<class T> using vv = vector<V<T>>; template<class T> using VV = vector<V<T>>; #define fi first #define se second #define maxs(x,y) (x=max(x,y)) #define mins(x,y) (x=min(x,y)) using pii = pair<int,int>; using pll = pair<ll,ll>; #define FOR(i,a,b) for(ll i = (a); i < (ll)(b); ++i) #define REP(i,n) FOR(i,0,n) #define RFOR(i,a,b) for(ll i = (ll)(b)-1;i >= a;--i) #define RREP(i,n) RFOR(i,0,n) #define ALL(obj) (obj).begin(), (obj).end() #define rALL(obj) (obj).rbegin(), (obj).rend() #define eb(val) emplace_back(val) const double PI = acos(-1); const double EPS = 1e-10; const ll MOD = 1e9+7; void cioacc(){//accelerate cin/cout cin.tie(0); ios::sync_with_stdio(false); } signed main(){ int n,d; cin >> n >> d; vi ab; REP(i,n){ int k = (i+1)*(i+1)+d; REP(j,n){ int x = k-(j+1)*(j+1); if(x>=2) ab.eb(x); } } sort(ALL(ab)); ll ans = 0; REP(i,n){ int k = (i+1)*(i+1); REP(j,n){ int x = k+(j+1)*(j+1); ans += upper_bound(ALL(ab),x)-lower_bound(ALL(ab),x); } } cout << ans << endl; }