結果
| 問題 |
No.800 四平方定理
|
| コンテスト | |
| ユーザー |
🍮かんプリン
|
| 提出日時 | 2019-04-08 09:23:38 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
AC
|
| 実行時間 | 92 ms / 2,000 ms |
| コード長 | 1,120 bytes |
| コンパイル時間 | 709 ms |
| コンパイル使用メモリ | 74,528 KB |
| 実行使用メモリ | 65,704 KB |
| 最終ジャッジ日時 | 2024-07-01 22:47:45 |
| 合計ジャッジ時間 | 2,775 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 30 |
ソースコード
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <string>
#include <queue>
#include <stack>
#include <math.h>
#include <set>
#define ALL(obj) (obj).begin(),(obj).end()
#define RALL(obj) (obj).rbegin(),(obj).rend()
#define P pair<int,int>
#define MOD 1000000007
#define INF 2147483647
#define NINF (-2147483647-1)
#define LLINF 9223372036854775807
using ll = long long;
using namespace std;
int main() {
int N, D;
cin >> N >> D;
vector<int> XY(2 * N * N + 1, 0), ZW(2 * N * N + 1, 0);
for (int x = 1; x <= N; x++)
{
for (int y = 1; y <= N; y++)
{
XY[x*x + y*y]++;
}
}
for (int w = 1; w <= N; w++)
{
for (int z = 1; z <= N; z++)
{
int k = w * w - z * z + D;
if (k >= 2 && k <= 2 * N * N) {
ZW[k]++;
}
else if (k <= 1) {
break;
}
}
}
ll cnt = 0;
for (int i = 0; i <= 2 * N * N; i++)
{
cnt += XY[i] * ZW[i];
}
cout << cnt << endl;
getchar(); getchar();
return 0;
}
🍮かんプリン