結果
| 問題 |
No.800 四平方定理
|
| コンテスト | |
| ユーザー |
eto_nagisa
|
| 提出日時 | 2019-03-18 04:25:31 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 254 ms / 2,000 ms |
| コード長 | 1,162 bytes |
| コンパイル時間 | 1,334 ms |
| コンパイル使用メモリ | 167,960 KB |
| 実行使用メモリ | 190,720 KB |
| 最終ジャッジ日時 | 2024-07-08 11:09:03 |
| 合計ジャッジ時間 | 5,692 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 30 |
ソースコード
#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;
int sz = max(n*n, d) + 2 * n * n + 1;
vl a(sz, 0), b(sz, 0);
REP(i, n)REP(j, n) {
ll x = i + 1, y = j + 1;
a[x*x + y * y + n * n]++;
b[x*x - y * y + d + n * n]++;
}
ll ans = 0;
REP(i, sz)ans += a[i] * b[i];
cout << ans << endl;
}
eto_nagisa