結果

問題 No.219 巨大数の概算
ユーザー mobius_bkstmobius_bkst
提出日時 2015-05-30 13:46:13
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 28 ms / 1,500 ms
コード長 1,116 bytes
コンパイル時間 598 ms
コンパイル使用メモリ 60,988 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-04-16 17:57:57
合計ジャッジ時間 4,308 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

//============================================================================
// Name        : yukicoder219.cpp
// Author      :
// Version     :
// Copyright   : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================

#include <iostream>
#include<math.h>
using namespace std;

int main() {

	double logarithmTable[100];

	for (int i = 10; i < 100; i++) {
		logarithmTable[i] = log10(i * 0.1);
	}

	int N;
	cin >> N;

	for (int i = 0; i < N; i++) {
		long A;
		long B;
		cin >> A >> B;
		long double ans = B * log10(A);
		long Z = (long)floor(ans);
		long double decimalPart = ans - Z;
		int high = 100;
		int low = 10;
		int mid;
		while (low < high) {
			mid = (high + low) / 2;
			if (decimalPart == logarithmTable[mid]) {
				break;
			} else if (decimalPart < logarithmTable[mid]) {
				high = mid;
			} else {
				low = mid + 1;
			}
		}

		double XY = mid * 0.1;
		int X = (int) floor(XY);
		int Y = (int) ((XY - X) * 10);
		cout << X << " " << Y << " " << Z << endl; // prints !!!Hello World!!!
	}

	return 0;
}

0