結果
| 問題 |
No.800 四平方定理
|
| コンテスト | |
| ユーザー |
kyort0n
|
| 提出日時 | 2019-03-17 21:26:50 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 99 ms / 2,000 ms |
| コード長 | 689 bytes |
| コンパイル時間 | 1,552 ms |
| コンパイル使用メモリ | 166,928 KB |
| 実行使用メモリ | 64,640 KB |
| 最終ジャッジ日時 | 2024-07-07 20:20:12 |
| 合計ジャッジ時間 | 3,693 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 30 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> l_l;
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
//const ll mod = 1000000007;
int N, D;
ll to[10000000];
int main() {
//cout.precision(10);
cin.tie(0);
ios::sync_with_stdio(false);
cin >> N >> D;
for(int i = 1; i <= N; i++) {
for(int j = 1; j <= N; j++) {
int ans = i * i + j * j;
to[ans]++;
}
}
ll ans = 0;
for(ll x = 1; x <= N; x++) {
for(ll w = 1; w <= N; w++) {
ll tmp = D + w * w - x * x;
if(tmp > 0) ans += to[tmp];
}
}
cout << ans << endl;
return 0;
}
kyort0n