結果

問題 No.1631 Sorting Integers (Multiple of K) Easy
ユーザー H3PO4H3PO4
提出日時 2023-10-15 18:24:46
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 907 bytes
コンパイル時間 898 ms
コンパイル使用メモリ 78,392 KB
実行使用メモリ 67,728 KB
最終ジャッジ日時 2023-10-15 18:24:56
合計ジャッジ時間 10,571 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,352 KB
testcase_01 AC 2 ms
4,348 KB
testcase_02 AC 2 ms
4,352 KB
testcase_03 AC 6 ms
4,348 KB
testcase_04 AC 1 ms
4,348 KB
testcase_05 AC 2 ms
4,352 KB
testcase_06 AC 2 ms
4,352 KB
testcase_07 AC 2 ms
4,352 KB
testcase_08 AC 2 ms
4,352 KB
testcase_09 AC 4 ms
4,348 KB
testcase_10 AC 2 ms
4,348 KB
testcase_11 AC 2 ms
4,352 KB
testcase_12 AC 2 ms
4,348 KB
testcase_13 AC 2 ms
4,352 KB
testcase_14 AC 517 ms
64,340 KB
testcase_15 AC 567 ms
67,392 KB
testcase_16 AC 541 ms
67,584 KB
testcase_17 AC 567 ms
67,728 KB
testcase_18 AC 543 ms
67,392 KB
testcase_19 AC 543 ms
67,580 KB
testcase_20 AC 543 ms
67,580 KB
testcase_21 AC 475 ms
59,744 KB
testcase_22 AC 560 ms
66,332 KB
testcase_23 AC 533 ms
66,384 KB
testcase_24 AC 555 ms
66,524 KB
testcase_25 AC 525 ms
65,752 KB
testcase_26 WA -
testcase_27 AC 414 ms
49,748 KB
testcase_28 AC 165 ms
22,944 KB
testcase_29 AC 167 ms
23,052 KB
testcase_30 AC 245 ms
32,644 KB
testcase_31 AC 388 ms
49,236 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <vector>

int main() {
    int N, K;
    std::cin >> N >> K;
    std::vector<int> X(N, 0);
    int ct = 0;
    int div = 1;
    for (int i = 1; i < 10; i++) {
        int c;
        std::cin >> c;
        for (int j = 1; j <= c; j++) {
            div *= j;
        }
        for (int j = 0; j < c; j++) {
            X.at(ct) = i;
            ct++;
        }
    }

    std::vector<std::vector<int>> A(1 << N, std::vector<int>(K));
    A.at(0).at(0) = 1;

    for (int b = 0; b < 1 << N; b++) {
        for (int i = 0; i < N; i++) {
            if (!(b & (1 << i))) {
                int c = b | (1 << i);
                for (int k = 0; k < K; k++) {
                    int next_k = (k * 10 + X.at(i)) % K;
                    A.at(c).at(next_k) += A.at(b).at(k);
                }
            }
        }
    }
    std::cout << A.at((1 << N) - 1).at(0) / div << std::endl;
}
0