結果
| 問題 |
No.2271 平方根の13桁精度近似計算
|
| コンテスト | |
| ユーザー |
Kude
|
| 提出日時 | 2023-04-14 22:30:55 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 1,246 ms / 2,000 ms |
| コード長 | 1,541 bytes |
| コンパイル時間 | 2,468 ms |
| コンパイル使用メモリ | 218,936 KB |
| 最終ジャッジ日時 | 2025-02-12 07:15:23 |
|
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 40 |
ソースコード
#include<bits/stdc++.h>
namespace {
#pragma GCC diagnostic ignored "-Wunused-function"
#include<atcoder/all>
#pragma GCC diagnostic warning "-Wunused-function"
using namespace std;
using namespace atcoder;
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define rrep(i,n) for(int i = (int)(n) - 1; i >= 0; i--)
#define all(x) begin(x), end(x)
#define rall(x) rbegin(x), rend(x)
template<class T> bool chmax(T& a, const T& b) { if (a < b) { a = b; return true; } else return false; }
template<class T> bool chmin(T& a, const T& b) { if (b < a) { a = b; return true; } else return false; }
using ll = long long;
using P = pair<int,int>;
using VI = vector<int>;
using VVI = vector<VI>;
using VL = vector<ll>;
using VVL = vector<VL>;
constexpr int pow5(int e) {
int res = 1;
rep(_, e) res *= 5;
return res;
}
template<int e>
void solve(int n) {
if (e == 0) {
cout << 0 << '\n';
return;
}
constexpr int mod = pow5(e);
using mint = static_modint<mod>;
constexpr int mx = min(1 << 29, (mod + 1) / 2);
mint tgt = n;
for(int i = 0; i <= mx; i++) {
mint r = mint::raw(i);
mint r2 = r * r;
if (r2 == tgt) {
cout << r.val() << '\n';
return;
}
}
cout << "NaN\n";
}
template<int e>
void select_solver(int n, int e_in) {
if (e_in == e) solve<e>(n);
else select_solver<e-1>(n, e_in);
}
template<>
void select_solver<-1>(int, int) {
assert(false);
}
} int main() {
ios::sync_with_stdio(false);
cin.tie(0);
int n, e;
cin >> n >> e;
select_solver<13>(n, e);
cout << flush;
}
Kude