結果
問題 | No.800 四平方定理 |
ユーザー |
![]() |
提出日時 | 2019-10-07 05:19:02 |
言語 | C++11 (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 99 ms / 2,000 ms |
コード長 | 912 bytes |
コンパイル時間 | 726 ms |
コンパイル使用メモリ | 87,412 KB |
実行使用メモリ | 81,360 KB |
最終ジャッジ日時 | 2024-10-12 07:50:32 |
合計ジャッジ時間 | 3,787 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 30 |
ソースコード
#include<iostream>#include<string>#include<vector>#include<algorithm>#include<bitset>#include<set>#include<map>#include<stack>#include<queue>#include<deque>#include<list>#include<iomanip>#include<cmath>#include<cstring>#include<functional>using namespace std;#define repr(i, a, b) for (int i = (int)(a); i < (int)(b); i++)#define rep(i, n) repr(i, 0, n)#define INF 2e9#define MOD 1000000007//#define MOD 998244353#define LINF (long long)4e18#define jck 3.141592using ll = long long;using Pi = pair<int,int>;using Pl = pair<ll,ll>;int main(){int N,D; cin >> N >> D;vector<int> cnt1(10000000);vector<int> cnt2(10000000);repr(x,1,N+1)repr(y,1,N+1){cnt1[x*x+y*y]++;}repr(z,1,N+1)repr(w,1,N+1){if(w*w-z*z+D >= 0) cnt2[w*w-z*z+D]++;}ll ans = 0;rep(i,10000000){ans += cnt1[i]*cnt2[i];}cout << ans << endl;}