結果

問題 No.1644 Eight Digits
ユーザー merlinmerlin
提出日時 2021-08-13 21:31:16
言語 Java21
(openjdk 21)
結果
AC  
実行時間 64 ms / 1,000 ms
コード長 870 bytes
コンパイル時間 2,164 ms
コンパイル使用メモリ 75,280 KB
実行使用メモリ 37,368 KB
最終ジャッジ日時 2024-04-14 16:49:37
合計ジャッジ時間 5,039 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 62 ms
37,212 KB
testcase_01 AC 63 ms
36,932 KB
testcase_02 AC 63 ms
37,172 KB
testcase_03 AC 63 ms
36,676 KB
testcase_04 AC 62 ms
36,744 KB
testcase_05 AC 62 ms
36,840 KB
testcase_06 AC 62 ms
36,944 KB
testcase_07 AC 62 ms
36,600 KB
testcase_08 AC 62 ms
36,856 KB
testcase_09 AC 63 ms
36,896 KB
testcase_10 AC 61 ms
36,740 KB
testcase_11 AC 62 ms
37,000 KB
testcase_12 AC 62 ms
37,004 KB
testcase_13 AC 62 ms
36,568 KB
testcase_14 AC 61 ms
37,160 KB
testcase_15 AC 63 ms
37,272 KB
testcase_16 AC 62 ms
36,896 KB
testcase_17 AC 63 ms
37,148 KB
testcase_18 AC 62 ms
37,188 KB
testcase_19 AC 64 ms
36,832 KB
testcase_20 AC 62 ms
37,352 KB
testcase_21 AC 62 ms
36,928 KB
testcase_22 AC 63 ms
36,996 KB
testcase_23 AC 63 ms
36,724 KB
testcase_24 AC 62 ms
36,980 KB
testcase_25 AC 64 ms
37,368 KB
testcase_26 AC 61 ms
37,040 KB
testcase_27 AC 63 ms
36,892 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

class Main
{
    public static void main(String args[])throws Exception
    {
        BufferedReader bu=new BufferedReader(new InputStreamReader(System.in));
        StringBuilder sb=new StringBuilder();
        k=Integer.parseInt(bu.readLine());
        ans=0;
        permute(0,7);
        System.out.println(ans);
    }

    static int k,ans;
    static char s[]="12345678".toCharArray();
    static void permute(int l,int r)
    {
        int i;
        if(l==r)
        {
            int v=0;
            for(i=0;i<8;i++)
            v=10*v+s[i]-'0';
            if(v%k==0) ans++;
            return;
        }

        for(i=l;i<=r;i++)
        {
            char t=s[l];
            s[l]=s[i];
            s[i]=t;
            permute(l+1,r);

            t=s[l];
            s[l]=s[i];
            s[i]=t;
        }
    }
}
0