結果

問題 No.1644 Eight Digits
ユーザー tentententen
提出日時 2021-08-16 14:34:51
言語 Java21
(openjdk 21)
結果
AC  
実行時間 74 ms / 1,000 ms
コード長 1,293 bytes
コンパイル時間 2,305 ms
コンパイル使用メモリ 78,168 KB
実行使用メモリ 51,140 KB
最終ジャッジ日時 2024-04-17 17:18:33
合計ジャッジ時間 4,625 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 60 ms
50,520 KB
testcase_01 AC 58 ms
50,268 KB
testcase_02 AC 72 ms
50,488 KB
testcase_03 AC 64 ms
50,652 KB
testcase_04 AC 73 ms
51,036 KB
testcase_05 AC 73 ms
50,856 KB
testcase_06 AC 64 ms
51,140 KB
testcase_07 AC 69 ms
50,580 KB
testcase_08 AC 60 ms
50,700 KB
testcase_09 AC 59 ms
50,624 KB
testcase_10 AC 72 ms
50,812 KB
testcase_11 AC 58 ms
50,572 KB
testcase_12 AC 59 ms
50,396 KB
testcase_13 AC 72 ms
50,700 KB
testcase_14 AC 60 ms
51,088 KB
testcase_15 AC 60 ms
50,528 KB
testcase_16 AC 61 ms
50,668 KB
testcase_17 AC 61 ms
50,292 KB
testcase_18 AC 73 ms
51,100 KB
testcase_19 AC 67 ms
50,672 KB
testcase_20 AC 74 ms
51,080 KB
testcase_21 AC 64 ms
51,088 KB
testcase_22 AC 64 ms
51,092 KB
testcase_23 AC 63 ms
51,044 KB
testcase_24 AC 59 ms
50,880 KB
testcase_25 AC 69 ms
51,064 KB
testcase_26 AC 60 ms
50,528 KB
testcase_27 AC 59 ms
50,168 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

public class Main {
    static int k;
    static int ans = 0;
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner();
        k = sc.nextInt();
        check(0, 0, new boolean[8]);
        System.out.println(ans);
    }
    
    static void check(int value, int idx, boolean[] used) {
        if (idx == 8) {
            if (value % k == 0) {
                ans++;
            }
            return;
        }
        for (int i = 0; i < 8; i++) {
            if (!used[i]) {
                used[i] = true;
                check(value * 10 + i + 1, idx + 1, used);
                used[i] = false;
            }
        }
    }
}
class Scanner {
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    StringTokenizer st = new StringTokenizer("");
    
    public Scanner() throws Exception {
        
    }
    
    public int nextInt() throws Exception {
        return Integer.parseInt(next());
    }
    
    public long nextLong() throws Exception {
        return Long.parseLong(next());
    }
    
    public String next() throws Exception {
        if (!st.hasMoreTokens()) {
            st = new StringTokenizer(br.readLine());
        }
        return st.nextToken();
    }
}
0