結果
| 問題 |
No.800 四平方定理
|
| コンテスト | |
| ユーザー |
h28i_Hide
|
| 提出日時 | 2019-03-17 22:01:16 |
| 言語 | C++17(clang) (17.0.6 + boost 1.87.0) |
| 結果 |
RE
|
| 実行時間 | - |
| コード長 | 2,598 bytes |
| コンパイル時間 | 1,212 ms |
| コンパイル使用メモリ | 152,024 KB |
| 実行使用メモリ | 34,524 KB |
| 最終ジャッジ日時 | 2024-11-30 13:43:46 |
| 合計ジャッジ時間 | 7,988 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 RE * 1 |
| other | AC * 4 RE * 26 |
ソースコード
#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 1e18
const 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の親が2
vector<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の根をrx
ll ry = root(y); //yの根をry
if (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[4000000];
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){
ans+=tmp[i*i-j*j+D];
}
}
cout<<ans<<endl;
return 0;
}
h28i_Hide