結果
| 問題 |
No.1842 Decimal Point
|
| コンテスト | |
| ユーザー |
👑 potato167
|
| 提出日時 | 2025-04-17 11:11:57 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 125 ms / 2,000 ms |
| コード長 | 805 bytes |
| コンパイル時間 | 2,242 ms |
| コンパイル使用メモリ | 192,940 KB |
| 実行使用メモリ | 7,844 KB |
| 最終ジャッジ日時 | 2025-04-17 11:12:01 |
| 合計ジャッジ時間 | 4,294 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 5 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
using int64 = long long;
// Compute x^e mod m in O(log e)
int64 modpow(int64 x, int64 e, int64 m) {
int64 res = 1 % m;
x %= m;
while (e > 0) {
if (e & 1) res = (__int128)res * x % m;
x = (__int128)x * x % m;
e >>= 1;
}
return res;
}
int main(){
ios::sync_with_stdio(false);
cin.tie(nullptr);
int T;
cin >> T;
while (T--) {
int64 A, B, C;
cin >> A >> B >> C;
// We want the C-th digit after the decimal point of A/B.
// Let r = (A * 10^{C-1} mod B). Then the digit is floor(r*10 / B).
int64 pow10 = modpow(10, C - 1, B);
int64 r = (__int128)A * pow10 % B;
int64 digit = (r * 10) / B;
cout << digit << "\n";
}
return 0;
}
potato167