結果
| 問題 |
No.1593 Perfect Distance
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2021-07-09 21:40:30 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 87 ms / 2,000 ms |
| コード長 | 579 bytes |
| コンパイル時間 | 1,602 ms |
| コンパイル使用メモリ | 173,524 KB |
| 実行使用メモリ | 12,544 KB |
| 最終ジャッジ日時 | 2024-07-01 15:36:50 |
| 合計ジャッジ時間 | 2,702 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 17 |
ソースコード
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
void Main() {
ll N;
cin >> N;
ll N2 = N * N;
ll ans = 0;
set<ll> sq;
for (ll i = 1; i < N; ++i) {
ll i2 = i * i;
sq.insert(i2);
}
for (ll i = 1; i < N; ++i) {
ll x = i;
ll y2 = N2 - x * x;
if (sq.count(y2) > 0) {
++ans;
}
}
cout << ans << endl;
}
int main() {
ios::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
std::cout << std::fixed << std::setprecision(15);
Main();
return 0;
}