結果

問題 No.1339 循環小数
ユーザー tentententen
提出日時 2023-06-22 10:29:15
言語 Java21
(openjdk 21)
結果
TLE  
実行時間 -
コード長 2,204 bytes
コンパイル時間 4,063 ms
コンパイル使用メモリ 85,728 KB
実行使用メモリ 277,168 KB
最終ジャッジ日時 2023-09-12 05:11:24
合計ジャッジ時間 13,657 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 48 ms
54,544 KB
testcase_01 AC 78 ms
51,956 KB
testcase_02 AC 77 ms
52,076 KB
testcase_03 AC 75 ms
51,788 KB
testcase_04 AC 79 ms
52,224 KB
testcase_05 AC 77 ms
52,208 KB
testcase_06 AC 79 ms
52,276 KB
testcase_07 AC 77 ms
52,152 KB
testcase_08 AC 72 ms
52,152 KB
testcase_09 AC 81 ms
52,152 KB
testcase_10 AC 70 ms
52,104 KB
testcase_11 AC 433 ms
67,224 KB
testcase_12 AC 395 ms
70,092 KB
testcase_13 AC 283 ms
65,708 KB
testcase_14 AC 379 ms
67,276 KB
testcase_15 AC 316 ms
67,152 KB
testcase_16 AC 364 ms
67,476 KB
testcase_17 AC 399 ms
66,480 KB
testcase_18 AC 316 ms
65,544 KB
testcase_19 AC 282 ms
63,840 KB
testcase_20 AC 267 ms
63,216 KB
testcase_21 TLE -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
testcase_31 -- -
testcase_32 -- -
testcase_33 -- -
testcase_34 -- -
testcase_35 -- -
testcase_36 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

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

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner();
        int n = sc.nextInt();
        StringBuilder sb = new StringBuilder();
        while (n-- > 0) {
            int t = sc.nextInt();
            long mod = 1;
            HashMap<Long, Integer> counts = new HashMap<>();
            counts.put(1L, 0);
            int idx = 1;
            int ans = 0;
            while (true) {
                mod *= 10;
                mod %= t;
                if (mod == 0) {
                    ans = 1;
                    break;
                }
                if (counts.containsKey(mod)) {
                    ans = idx - counts.get(mod);
                    break;
                }
                counts.put(mod, idx);
                idx++;
            }
            sb.append(ans).append("\n");
        }
        System.out.print(sb);
    }
}

class Utilities {
    static String arrayToLineString(Object[] arr) {
        return Arrays.stream(arr).map(x -> x.toString()).collect(Collectors.joining("\n"));
    }
    
    static String arrayToLineString(int[] arr) {
        return String.join("\n", Arrays.stream(arr).mapToObj(String::valueOf).toArray(String[]::new));
    }
}
class Scanner {
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    StringTokenizer st = new StringTokenizer("");
    StringBuilder sb = new StringBuilder();
    
    public Scanner() throws Exception {
        
    }
    
    public int nextInt() throws Exception {
        return Integer.parseInt(next());
    }
    
    public long nextLong() throws Exception {
        return Long.parseLong(next());
    }
    
    public double nextDouble() throws Exception {
        return Double.parseDouble(next());
    }
    
    public int[] nextIntArray() throws Exception {
        return Stream.of(br.readLine().split(" ")).mapToInt(Integer::parseInt).toArray();
    }
    
    public String next() throws Exception {
        while (!st.hasMoreTokens()) {
            st = new StringTokenizer(br.readLine());
        }
        return st.nextToken();
    }
    
}
0