結果
問題 | No.800 四平方定理 |
ユーザー |
|
提出日時 | 2019-03-18 11:50:55 |
言語 | C++11 (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 78 ms / 2,000 ms |
コード長 | 930 bytes |
コンパイル時間 | 1,566 ms |
コンパイル使用メモリ | 158,504 KB |
実行使用メモリ | 64,364 KB |
最終ジャッジ日時 | 2024-07-18 05:02:39 |
合計ジャッジ時間 | 3,427 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 30 |
ソースコード
#include <bits/stdc++.h>typedef long long ll;#define rep(i,m,n) for(ll i = (m); i < (n); i++)#define rrep(i,m,n) for(ll i = (m); i >= (n); i--)#define print(x) cout << (x) << endl;#define print2(x,y) cout << (x) << " " << (y) << endl;#define printa(x,n) for(ll i = 0; i < n; i++){ cout << (x[i]) << " \n"[i == n-1];}#define printp(x,n) for(ll i = 0; i < n; i++){ cout << "(" << x[i].first << ", " << x[i].second << ") "; } cout << endl;#define INF (1e18 + 7)using namespace std;const ll MOD = 1e9 + 7;typedef pair<ll, ll> lpair;ll cnt[8000010] = {};int main(){cin.tie(0);ios::sync_with_stdio(false);ll N,D;cin >> N >> D;rep(x,1,N+1){rep(y,1,N+1){cnt[x*x+y*y]++;}}ll ans = 0;rep(z,1,N+1){rep(w,1,N+1){ll v = D + w*w - z*z;if(v <= 0) continue;ans += cnt[v];}}print(ans);}