結果
| 問題 | No.2976 高階多点評価 |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2026-08-04 23:08:23 |
| 言語 | C++23 (gcc 15.2.0 + boost 1.90.0) |
| 結果 |
RE
|
| 実行時間 | - |
| コード長 | 1,639 bytes |
| 記録 | |
| コンパイル時間 | 7,586 ms |
| コンパイル使用メモリ | 674,228 KB |
| 実行使用メモリ | 5,888 KB |
| 最終ジャッジ日時 | 2026-08-04 23:09:01 |
| 合計ジャッジ時間 | 37,175 ms |
|
ジャッジサーバーID (参考情報) |
judge2_1 / judge1_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | RE * 22 TLE * 16 |
ソースコード
#include <bits/extc++.h>
#include <boost/multiprecision/cpp_int.hpp>
int main() {
using namespace std;
using bigint = boost::multiprecision::cpp_int;
unsigned T;
cin >> T;
for ([[maybe_unused]] const auto _ : views::repeat(monostate{}, T)) [] {
unsigned N;
double _x;
cin >> N >> _x;
int X = round(_x * 100000), Y = 100000;
int g{gcd(X, Y)};
X /= g;
Y /= g;
bigint real = 1, imag = 0;
for (unsigned i{8}; i--; ) {
tie(real, imag) = pair<bigint, bigint>{real * real - imag * imag, real * imag * 2};
if (N + 1 >> i & 1)
tie(real, imag) = pair<bigint, bigint>{-real * X - imag * Y, real * Y - imag * X};
}
long abs_sq = static_cast<long>(X) * X + static_cast<long>(Y) * Y;
int abs_round = round(sqrt(abs_sq));
bigint ans;
if (abs_sq == static_cast<long>(abs_round) * abs_round) {
bigint abs_ans = boost::multiprecision::pow(bigint{abs_round}, N);
ans = max(imag, -imag) * g / abs_ans;
} else {
bigint abs_ans = boost::multiprecision::pow(bigint{abs_sq}, N);
bigint mag_sq = imag * imag * g * g / abs_ans;
ans = static_cast<bigint>(sqrt(static_cast<double>(mag_sq)) + 1);
if (mag_sq != 0) {
do {
ans = (ans + mag_sq / ans) / 2;
} while (mag_sq / ans / ans == 0);
}
}
cout << (imag < 0 ? "-" : "") << ans / 100000 << "." << setw(5) << setfill('0') << ans % 100000 << endl;
}();
abort();
return 0;
}