結果
問題 | No.800 四平方定理 |
ユーザー |
![]() |
提出日時 | 2020-08-24 23:55:29 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 90 ms / 2,000 ms |
コード長 | 716 bytes |
コンパイル時間 | 1,569 ms |
コンパイル使用メモリ | 168,960 KB |
実行使用メモリ | 65,844 KB |
最終ジャッジ日時 | 2024-11-06 10:54:40 |
合計ジャッジ時間 | 4,389 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 30 |
ソースコード
#include<bits/stdc++.h>#define rep(i,N) for(ll (i)=0;(i)<(N);(i)++)#define chmax(x,y) x=max(x,y)#define chmin(x,y) x=min(x,y)using namespace std;typedef long long ll;typedef pair<int,int> P;const int mod = 1000000007;const int INF = 1001001001;const int MAXV = 2000 * 2000 + 2000 * 2000 + 1;int main() {int n, d;cin >> n >> d;vector<int> a(MAXV), b(MAXV);for (int i = 1; i <= n; ++i) for (int j = 1; j <= n; ++j) {int v = i * i + j * j;a[v]++;}for (int i = 1; i <= n; ++i) for (int j = 1; j <= n; ++j) {int v = i * i - j * j + d;if (v >= MAXV || v < 0) continue;b[v]++;}ll ans = 0;rep(i, MAXV) {ans += a[i] * b[i];}cout << ans << endl;}