//============================================================================ // Name : yukicoder219.cpp // Author : // Version : // Copyright : Your copyright notice // Description : Hello World in C++, Ansi-style //============================================================================ #include #include 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; }