結果
| 問題 |
No.800 四平方定理
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2019-05-01 23:08:34 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 42 ms / 2,000 ms |
| コード長 | 612 bytes |
| コンパイル時間 | 1,759 ms |
| コンパイル使用メモリ | 169,264 KB |
| 実行使用メモリ | 38,380 KB |
| 最終ジャッジ日時 | 2024-12-31 12:44:15 |
| 合計ジャッジ時間 | 3,006 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 30 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
int main(){
cin.tie(0);
ios::sync_with_stdio(false);
int N, D;
cin >> N >> D;
vector<int> freq(2 * N * N + 1 + D, 0);
for (int x = 1; x <= N; ++x){
++freq[x*x*2];
for (int y = x + 1; y <= N; ++y){
freq[x*x + y*y] += 2;
}
}
long long ans = 0;
for (int w = 1; w <= N; ++w){
int wd = w * w + D;
for (int z = 1; z <= N; ++z){
int tmp = wd - z * z;
if (tmp < 0) break;
ans += freq[tmp];
}
}
cout << ans << endl;
return 0;
}