結果
問題 | No.25 有限小数 |
ユーザー | uafr_cs |
提出日時 | 2017-11-11 10:10:55 |
言語 | Java21 (openjdk 21) |
結果 |
TLE
|
実行時間 | - |
コード長 | 974 bytes |
コンパイル時間 | 2,265 ms |
コンパイル使用メモリ | 75,864 KB |
実行使用メモリ | 80,356 KB |
最終ジャッジ日時 | 2024-05-03 16:26:18 |
合計ジャッジ時間 | 11,656 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 119 ms
41,560 KB |
testcase_01 | AC | 113 ms
41,064 KB |
testcase_02 | AC | 122 ms
41,332 KB |
testcase_03 | AC | 119 ms
41,452 KB |
testcase_04 | AC | 115 ms
40,744 KB |
testcase_05 | AC | 122 ms
41,236 KB |
testcase_06 | AC | 124 ms
41,444 KB |
testcase_07 | AC | 112 ms
40,120 KB |
testcase_08 | AC | 117 ms
41,260 KB |
testcase_09 | AC | 115 ms
40,852 KB |
testcase_10 | AC | 124 ms
41,356 KB |
testcase_11 | AC | 110 ms
39,956 KB |
testcase_12 | AC | 112 ms
40,460 KB |
testcase_13 | AC | 122 ms
41,212 KB |
testcase_14 | AC | 122 ms
41,216 KB |
testcase_15 | AC | 107 ms
40,216 KB |
testcase_16 | AC | 108 ms
39,956 KB |
testcase_17 | AC | 124 ms
41,412 KB |
testcase_18 | AC | 110 ms
39,936 KB |
testcase_19 | TLE | - |
testcase_20 | -- | - |
testcase_21 | -- | - |
testcase_22 | -- | - |
testcase_23 | -- | - |
testcase_24 | -- | - |
testcase_25 | -- | - |
testcase_26 | -- | - |
testcase_27 | -- | - |
testcase_28 | -- | - |
testcase_29 | -- | - |
testcase_30 | -- | - |
ソースコード
import java.math.BigInteger; import java.util.Arrays; import java.util.HashSet; import java.util.LinkedList; import java.util.Scanner; public class Main { public static long MOD = 1000000007; public static void main(String[] args) { Scanner sc = new Scanner(System.in); BigInteger N = new BigInteger(sc.next()); BigInteger M = new BigInteger(sc.next()); BigInteger answer = BigInteger.ZERO; HashSet<BigInteger> already = new HashSet<BigInteger>(); while(true){ //System.out.println(N + "/" + M); answer = answer.multiply(BigInteger.TEN); answer = answer.add(N.divide(M)); if(N.mod(M) == BigInteger.ZERO){ break; } final BigInteger mod = N.mod(M); if(already.contains(mod)){ System.out.println(-1); return; } already.add(mod); N = mod.multiply(BigInteger.TEN); } final String output = answer.toString().replace("0", ""); System.out.println(output.charAt(output.length() - 1)); } }