結果
| 問題 |
No.1842 Decimal Point
|
| コンテスト | |
| ユーザー |
tamato
|
| 提出日時 | 2022-02-18 22:39:06 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,010 bytes |
| コンパイル時間 | 260 ms |
| コンパイル使用メモリ | 82,432 KB |
| 実行使用メモリ | 78,636 KB |
| 最終ジャッジ日時 | 2024-06-29 09:25:15 |
| 合計ジャッジ時間 | 2,288 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 4 WA * 1 |
ソースコード
mod = 1000000007
eps = 10**-9
def main():
import sys
import math
input = sys.stdin.readline
inv = {1: 1, 3: 7, 7: 3, 9: 9}
for _ in range(int(input())):
a, b, c = map(int, input().split())
q = pow(10, c, b)
cnt2 = cnt5 = 0
while b % 2 == 0:
cnt2 += 1
b //= 2
q //= 2
while b % 5 == 0:
cnt5 += 1
b //= 5
q //= 5
cnt = max(cnt2, cnt5)
if cnt > c:
if cnt2 < cnt5:
a *= 2 ** (cnt5 - cnt2)
else:
a *= 5 ** (cnt2 - cnt5)
d = cnt - c
x = math.floor(a / b)
x = str(x).zfill(100)
print(x[-d - 1])
continue
r = (pow(2, c - cnt2, 10) * pow(5, c - cnt5, 10)) % 10
p = ((r-q) * inv[b % 10]) % 10
ans0 = (a * p) % 10
ans1 = math.floor(a * q / b) % 10
print((ans0 + ans1) % 10)
if __name__ == '__main__':
main()
tamato