結果
問題 | No.800 四平方定理 |
ユーザー |
![]() |
提出日時 | 2019-03-17 22:02:39 |
言語 | C++17(clang) (17.0.6 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 101 ms / 2,000 ms |
コード長 | 2,632 bytes |
コンパイル時間 | 1,176 ms |
コンパイル使用メモリ | 150,352 KB |
実行使用メモリ | 64,508 KB |
最終ジャッジ日時 | 2024-11-30 13:43:54 |
合計ジャッジ時間 | 3,474 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 30 |
ソースコード
#include <algorithm>#include <bitset>#include <complex>#include <deque>#include <exception>#include <fstream>#include <functional>#include <iomanip>#include <ios>#include <iosfwd>#include <iostream>#include <istream>#include <iterator>#include <limits>#include <list>#include <locale>#include <map>#include <memory>#include <new>#include <numeric>#include <ostream>#include <queue>#include <set>#include <sstream>#include <stack>#include <stdexcept>#include <streambuf>#include <string>#include <stdio.h>#include <typeinfo>#include <utility>#include <valarray>#include <vector>#define rep(i,a,n) for(ll i =(a);i<(n);++i)#define urep(i,a,n) for(ll i = (a);i>=(n);--i)#define all(x) (x).begin(),(x).end()#define INF 1e18const int mod = 1e9 + 7;typedef long long ll;using namespace std;ll dx[4] = { 1,-1,0,0 };ll dy[4] = { 0,0,1,-1 };ll N,M,X,Y,A,B,C,D,Q,K,R,W,H,P,L;ll ans;/*string S,T;ll y[101010];ll a[101010];ll b[101010];ll t[101010];ll p[101010];ll n[101010];ll l[101010];ll gcd(ll a, ll b) {if (b == 0)return a;else return gcd(b, a%b);}struct Edge{ll to,cost;Edge(ll to, ll cost) : to(to), cost(cost) {}};typedef vector<vector<Edge> > AdjList;AdjList graph;vector<ll> dist;struct UnionFind {vector<ll> par; // par[i]:iの親の番号 (例) par[3] = 2 : 3の親が2vector<ll> size;UnionFind(ll N) : par(N),size(N) { //最初は全てが根であるとして初期化for(ll i = 0; i < N; i++) par[i] = i;for(ll i = 0; i < N; i++) size[i] = 1;}ll root(ll x) { // データxが属する木の根を再帰で得る:root(x) = {xの木の根}if (par[x] == x) return x;return par[x] = root(par[x]);}ll GetSize(ll x){return size[root(x)];}void unite(ll x, ll y) { // xとyの木を併合ll rx = root(x); //xの根をrxll ry = root(y); //yの根をryif (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのままpar[rx] = ry; //xとyの根が同じでない(=同じ木にない)時:xの根rxをyの根ryにつけるsize[ry]+=size[rx];}bool same(ll x, ll y) { // 2つのデータx, yが属する木が同じならtrueを返すll rx = root(x);ll ry = root(y);return rx == ry;}};*/ll tmp[40000000];int main() {cin>>N>>D;map<ll,ll> mp1;rep(i,1,N+1){rep(j,1,N+1){tmp[i*i+j*j]++;}}rep(i,1,N+1){rep(j,1,N+1){if(i*i-j*j+D>=0)ans+=tmp[i*i-j*j+D];}}cout<<ans<<endl;return 0;}