結果

問題 No.219 巨大数の概算
ユーザー Yang33Yang33
提出日時 2018-08-23 19:14:00
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 55 ms / 1,500 ms
コード長 2,012 bytes
コンパイル時間 1,302 ms
コンパイル使用メモリ 165,864 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-08-27 06:30:02
合計ジャッジ時間 7,335 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

using VS = vector<string>;    using LL = long long;
using VI = vector<int>;       using VVI = vector<VI>;
using PII = pair<int, int>;   using PLL = pair<LL, LL>;
using VL = vector<LL>;        using VVL = vector<VL>;

#define ALL(a)  begin((a)),end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define SZ(a) int((a).size())
#define SORT(c) sort(ALL((c)))
#define RSORT(c) sort(RALL((c)))
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))
#define FOR(i, s, e) for (int(i) = (s); (i) < (e); (i)++)
#define FORR(i, s, e) for (int(i) = (s); (i) > (e); (i)--)
#define debug(x) cerr << #x << ": " << x << endl
const int INF = 1e9;                          const LL LINF = 1e16;
const LL MOD = 1000000007;                    const double PI = acos(-1.0);
int DX[8] = { 0, 0, 1, -1, 1, 1, -1, -1 };    int DY[8] = { 1, -1, 0, 0, 1, -1, 1, -1 };

/* -----  2018/08/23  Problem: yukicoder 219  / Link: http://yukicoder.me/problems/no/219  ----- */
/* ------問題------

累乗数の概算をしたいと思います。
AB≒X.Y∗10Z (A,B,X,Y,Zは整数、Xは1以上9以下、Yは0以上9以下、なおYより下位は切り捨てとする)
A,Bが複数与えられるので、あてはまるX,Y,Zを求めて下さい。なおZは0になることはないとします。

ただし、誤差の許容として、有効な出力をそれが表現する値で順序付けした時、想定解の出力の1つ隣に該当する値も許容する。

-----問題ここまで----- */
/* -----解説等-----



----解説ここまで---- */

int main() {
	cin.tie(0);
	ios_base::sync_with_stdio(false);

	int N; cin >> N;
	FOR(i, 0, N) {
		double A, B; cin >> A >> B;
		double val = B * log10(A);
		LL Z = val;
		val -= Z;
		int XY = -1;
		double Diff = INF;
		FOR(j, 10, 100) {
			double x = j / 10.0;
			if (abs((val)-log10(x)) < Diff) {
				Diff = abs((val) - log10(x));
				XY = j;
			}
		}
		
		cout << XY / 10 << " " << XY % 10 << " " << Z << endl;
	}

	return 0;
}
0