結果
問題 | No.1644 Eight Digits |
ユーザー |
![]() |
提出日時 | 2021-08-13 21:26:38 |
言語 | Java (openjdk 23) |
結果 |
AC
|
実行時間 | 233 ms / 1,000 ms |
コード長 | 585 bytes |
コンパイル時間 | 2,355 ms |
コンパイル使用メモリ | 75,140 KB |
実行使用メモリ | 46,796 KB |
最終ジャッジ日時 | 2024-10-03 17:04:36 |
合計ジャッジ時間 | 9,687 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 25 |
ソースコード
import java.util.LinkedHashSet;import java.util.Scanner;public class Main {static int k, ans;public static void main(String[] args) throws Exception {Scanner sc = new Scanner(System.in);k = sc.nextInt();sc.close();permutation(0, new LinkedHashSet<>());System.out.println(ans);}static void permutation(int x, LinkedHashSet<Integer> set) {if (x > 10000000) {if (x % k == 0) {ans++;}return;}for (int i = 1; i <= 8; i++) {if (!set.contains(i)) {set.add(i);permutation(x * 10 + i, set);set.remove(i);}}}}