結果
| 問題 |
No.800 四平方定理
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2019-04-18 05:16:28 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
RE
|
| 実行時間 | - |
| コード長 | 482 bytes |
| コンパイル時間 | 1,685 ms |
| コンパイル使用メモリ | 166,396 KB |
| 実行使用メモリ | 65,748 KB |
| 最終ジャッジ日時 | 2024-09-22 08:45:09 |
| 合計ジャッジ時間 | 8,375 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 17 RE * 13 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for (int i=0;i<(n);i++)
#define REP2(i,m,n) for (int i=m;i<(n);i++)
typedef long long ll;
const ll M = 2000 * 2000;
ll N, D;
ll cnt[M*2+1];
void solve() {
cin >> N >> D;
ll ans = 0;
REP2 (z, 1, N+1) REP2 (w, 1, N+1) cnt[z*z-w*w+M] += 1;
REP2 (x, 1, N+1) REP2 (y, 1, N+1) ans += cnt[D-x*x-y*y+M];
cout << ans << endl;
}
int main() {
cin.tie(0);
ios::sync_with_stdio(false);
solve();
}