結果

問題 No.2271 平方根の13桁精度近似計算
ユーザー jinya nakamurajinya nakamura
提出日時 2023-04-15 01:51:19
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,072 bytes
コンパイル時間 2,081 ms
コンパイル使用メモリ 198,096 KB
実行使用メモリ 6,948 KB
最終ジャッジ日時 2024-04-18 22:56:27
合計ジャッジ時間 5,873 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 AC 2 ms
5,376 KB
testcase_02 WA -
testcase_03 WA -
testcase_04 AC 2 ms
5,376 KB
testcase_05 AC 2 ms
5,376 KB
testcase_06 AC 2 ms
5,376 KB
testcase_07 AC 2 ms
5,376 KB
testcase_08 AC 2 ms
5,376 KB
testcase_09 AC 2 ms
5,376 KB
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 AC 2 ms
5,376 KB
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 AC 2 ms
5,376 KB
testcase_19 WA -
testcase_20 WA -
testcase_21 AC 2 ms
5,376 KB
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 AC 2 ms
5,376 KB
testcase_26 WA -
testcase_27 AC 2 ms
5,376 KB
testcase_28 WA -
testcase_29 WA -
testcase_30 AC 2 ms
5,376 KB
testcase_31 WA -
testcase_32 AC 2 ms
5,376 KB
testcase_33 WA -
testcase_34 WA -
testcase_35 WA -
testcase_36 AC 2 ms
5,376 KB
testcase_37 AC 1 ms
5,376 KB
testcase_38 WA -
testcase_39 AC 2 ms
5,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
// typedef unsigned long long ull;
// const ll INF = numeric_limits<ll>::max() / 4;
// const int INF = numeric_limits<int>::max() / 4;
// cout << std::fixed << std::setprecision(15);


int main() {
	ll N; int E;
	cin >> N >> E;
	int K = 20;
	ll EPS = 1;
	for(int i = 0; i < K; i++) EPS *= 5;
	if(N < 0) N += EPS;
	vector<ll> T(K, 0);
	for(int k = 0; k < K; k++){
		T[k] = N % 5LL;
		N /= 5;
	}
	vector<ll> R(K, 0);
	vector<ll> U(K, 0);
	for(int e = 0; e <= E; e++){
		ll l = U[e];
		U[e] = 0;
		for(int j = 1; j <= e - 1; j++){
			l += R[j] * R[e - j];
		}
		bool f = false;
		for(R[e] = 0; R[e] < 5; R[e]++){
			ll s = R[e] * R[0] * 2;
			if(e == 0) s = R[0] * R[0];
			if((l + s) % 5 == T[e]){
				l += s;
				l /= 5;
				for(int j = e + 1; j < K; j++){
					U[j] += l % 5;
					l /= 5;
				}
				f = true;
				break;
			}
		}
		if(!f){
			cout << "NaN" << endl;
			return 0;
		}
	}

	ll r = 0;
	ll d = 1;
	for(int k = 0; k <= K; k++){
		r += R[k] * d;
		d *= 5LL;
	}

	cout << r << endl;
	return 0;
}
0