結果
| 問題 | No.1593 Perfect Distance |
| コンテスト | |
| ユーザー |
ldsyb
|
| 提出日時 | 2026-09-12 01:42:41 |
| 言語 | C++23 (gcc 15.3.0 + boost 1.92.0 + ACL) |
| 結果 |
AC
不安定
|
| 実行時間 | 27 ms / 2,000 ms |
| + 977µs | |
| コード長 | 626 bytes |
| 記録 | |
| コンパイル時間 | 4,069 ms |
| コンパイル使用メモリ | 374,876 KB |
| 実行使用メモリ | 6,400 KB |
| 最終ジャッジ日時 | 2026-09-12 01:42:53 |
| 合計ジャッジ時間 | 5,631 ms |
|
ジャッジサーバーID (参考情報) |
judge1_0 / judge3_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 17 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
using namespace chrono;
#if __has_include(<atcoder/all>)
#include <atcoder/all>
using namespace atcoder;
#endif
int main() {
int64_t n;
cin >> n;
auto f = [](int64_t x) -> bool {
int64_t ok = 1, ng = (1LL << 30);
while (1 < abs(ok - ng)) {
int64_t mid = midpoint(ok, ng);
((mid * mid <= x) ? ok : ng) = mid;
}
return ok * ok == x;
};
int64_t ans = 0;
for (int64_t x = 1; x <= n; x++) {
if (f(n * n - x * x)) {
ans++;
}
}
cout << ans << endl;
return 0;
}
ldsyb