結果

問題 No.1842 Decimal Point
ユーザー ripityripity
提出日時 2022-02-18 21:30:58
言語 Java21
(openjdk 21)
結果
AC  
実行時間 1,124 ms / 2,000 ms
コード長 886 bytes
コンパイル時間 2,661 ms
コンパイル使用メモリ 71,608 KB
実行使用メモリ 65,424 KB
最終ジャッジ日時 2023-09-11 18:35:08
合計ジャッジ時間 8,069 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 126 ms
55,980 KB
testcase_01 AC 874 ms
64,336 KB
testcase_02 AC 1,124 ms
64,992 KB
testcase_03 AC 1,075 ms
65,424 KB
testcase_04 AC 979 ms
65,296 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;
import java.io.*;

public class Main {
    
    public static Scanner sc = new Scanner(System.in);
    public static PrintWriter pw = new PrintWriter(System.out);
    
    public static void main(String[] args) {
        
        int t = sc.nextInt();
        while( t > 0 ) {
            solve();
            t--;
        }
        
        pw.flush();
        
    }
    
    static void solve() {
        
        long A = sc.nextInt();
        long B = sc.nextInt();
        long C = sc.nextInt();
        A %= B;
        A *= modpow(10,C-1,B);
        A %= B;
        A *= 10;
        pw.println(A/B);
        
    }
    
    static long modpow( long x, long n, long mod ) {
		
		if( n == 0 ) {
			return 1;
		}
		
		long k = 1;
		while( n > 1 ) {
			if( n%2 == 1 ) k *= x;
			x *= x;
			n /= 2;
			x %= mod;
			k %= mod;
		}
		
		return (k*x)%mod;
		
	}
    
}
0