結果
| 問題 | No.2976 高階多点評価 |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2026-08-04 22:49:03 |
| 言語 | C++23 (gcc 15.2.0 + boost 1.90.0) |
| 結果 |
RE
|
| 実行時間 | - |
| コード長 | 1,521 bytes |
| 記録 | |
| コンパイル時間 | 9,193 ms |
| コンパイル使用メモリ | 671,004 KB |
| 実行使用メモリ | 5,888 KB |
| 最終ジャッジ日時 | 2026-08-04 22:49:42 |
| 合計ジャッジ時間 | 36,078 ms |
|
ジャッジサーバーID (参考情報) |
judge2_0 / judge1_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 21 RE * 4 TLE * 13 |
ソースコード
#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 = 0;
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 = mag_sq;
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;
}();
return 0;
}