結果
問題 | No.1593 Perfect Distance |
ユーザー |
![]() |
提出日時 | 2021-07-10 11:40:49 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 16 ms / 2,000 ms |
コード長 | 649 bytes |
コンパイル時間 | 789 ms |
コンパイル使用メモリ | 91,676 KB |
実行使用メモリ | 5,376 KB |
最終ジャッジ日時 | 2024-07-02 01:51:36 |
合計ジャッジ時間 | 1,536 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 17 |
ソースコード
#include <iostream> #include <vector> #include <algorithm> #include <functional> #include <queue> #include <map> #include <cmath> #include <iomanip> using namespace std; const long long MOD = (long long)(1e9) + 7; int main() { //cout << fixed << setprecision(15); long long n; cin >> n; int ans = 0; for (long long x = 1; x <= n; x++) { long long ok = n + 1; long long ng = 0; while (ok - ng > 1) { long long mid = (ok + ng) / 2; if (x * x + mid * mid >= n * n) { ok = mid; } else { ng = mid; } } if (x * x + ok * ok == n * n) ans++; } cout << ans << endl; return 0; }