結果

問題 No.219 巨大数の概算
ユーザー startcppstartcpp
提出日時 2015-06-02 17:39:43
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 27 ms / 1,500 ms
コード長 868 bytes
コンパイル時間 378 ms
コンパイル使用メモリ 60,028 KB
実行使用メモリ 4,500 KB
最終ジャッジ日時 2023-09-25 14:16:15
合計ジャッジ時間 4,756 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 27 ms
4,380 KB
testcase_01 AC 27 ms
4,380 KB
testcase_02 AC 27 ms
4,376 KB
testcase_03 AC 26 ms
4,380 KB
testcase_04 AC 27 ms
4,376 KB
testcase_05 AC 2 ms
4,376 KB
testcase_06 AC 4 ms
4,376 KB
testcase_07 AC 1 ms
4,376 KB
testcase_08 AC 4 ms
4,376 KB
testcase_09 AC 2 ms
4,376 KB
testcase_10 AC 27 ms
4,380 KB
testcase_11 AC 27 ms
4,376 KB
testcase_12 AC 27 ms
4,380 KB
testcase_13 AC 26 ms
4,376 KB
testcase_14 AC 27 ms
4,380 KB
testcase_15 AC 26 ms
4,376 KB
testcase_16 AC 27 ms
4,380 KB
testcase_17 AC 26 ms
4,376 KB
testcase_18 AC 27 ms
4,380 KB
testcase_19 AC 26 ms
4,380 KB
testcase_20 AC 27 ms
4,380 KB
testcase_21 AC 26 ms
4,380 KB
testcase_22 AC 26 ms
4,380 KB
testcase_23 AC 26 ms
4,380 KB
testcase_24 AC 27 ms
4,384 KB
testcase_25 AC 27 ms
4,380 KB
testcase_26 AC 27 ms
4,376 KB
testcase_27 AC 27 ms
4,376 KB
testcase_28 AC 26 ms
4,376 KB
testcase_29 AC 26 ms
4,376 KB
testcase_30 AC 27 ms
4,376 KB
testcase_31 AC 26 ms
4,376 KB
testcase_32 AC 26 ms
4,376 KB
testcase_33 AC 27 ms
4,380 KB
testcase_34 AC 27 ms
4,376 KB
testcase_35 AC 27 ms
4,500 KB
testcase_36 AC 27 ms
4,380 KB
testcase_37 AC 27 ms
4,376 KB
testcase_38 AC 26 ms
4,380 KB
testcase_39 AC 26 ms
4,376 KB
testcase_40 AC 27 ms
4,380 KB
testcase_41 AC 26 ms
4,376 KB
testcase_42 AC 27 ms
4,380 KB
testcase_43 AC 27 ms
4,376 KB
testcase_44 AC 27 ms
4,376 KB
testcase_45 AC 27 ms
4,376 KB
testcase_46 AC 27 ms
4,376 KB
testcase_47 AC 27 ms
4,380 KB
testcase_48 AC 27 ms
4,376 KB
testcase_49 AC 26 ms
4,376 KB
testcase_50 AC 27 ms
4,380 KB
testcase_51 AC 1 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

//2.1 * 10^9以下の正整数a, bがn回与えられるので、各a, bについて、
//a^b = x.y * 10^z (1 <= x <= 9, 1 <= y <= 9, 1 <= z <= ?、x,y,zは全て整数)となるx, y, zを求め、出力する。
//答えは必ず存在すると仮定してよい。
#include<iostream>
#include<cmath>
#define int long long
using namespace std;

int n;

signed main() {
	cin >> n;
	while (n--) {
		int a, b;
		cin >> a >> b;
		
		//b = log(a)(a^b), z = log(10)(a^b)…
		//z = blog(10)(a)…、切り捨て誤差分(eps)を余分にたすと安全。
		double eps = 1e-10;
		int z = b * log10((double)a) + eps;
		
		//x.yは…、blog(10)(a)の小数部分をpとしたとき、
		//10^(p)で概算できる…。
		double r = pow(10, b * log10((double)a) + eps - z);
		int x = r;
		int y = (r - x)*10;
		
		cout << x << " " << y << " " << z << endl;
	}
	return 0;
}
0