結果
問題 |
No.1842 Decimal Point
|
ユーザー |
![]() |
提出日時 | 2025-08-04 17:14:23 |
言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 145 ms / 2,000 ms |
コード長 | 974 bytes |
コンパイル時間 | 3,337 ms |
コンパイル使用メモリ | 276,216 KB |
実行使用メモリ | 7,716 KB |
最終ジャッジ日時 | 2025-08-04 17:14:28 |
合計ジャッジ時間 | 4,727 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 5 |
ソースコード
#include <bits/stdc++.h> using namespace std; using int64 = long long; using i128 = __int128_t; // Compute x^e mod m using binary exponentiation int64 mod_pow(int64 x, int64 e, int64 m) { i128 result = 1; i128 base = x % m; while (e > 0) { if (e & 1) { result = (result * base) % m; } base = (base * base) % m; e >>= 1; } return (int64)result; } int main() { ios::sync_with_stdio(false); cin.tie(nullptr); int T; cin >> T; while (T--) { int64 A, B, C; cin >> A >> B >> C; // r0 = A mod B int64 r0 = A % B; // M = 10 * B int64 M = B * 10; // Compute p = (10^C) mod M int64 p = mod_pow(10, C, M); // t = (r0 * p) mod M int64 t = (int64)((i128)r0 * p % M); // The C-th digit after the decimal point is floor(t / B) int64 digit = t / B; cout << digit << "\n"; } return 0; }