結果

問題 No.1644 Eight Digits
ユーザー ytsmash
提出日時 2021-08-14 09:55:10
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
(最新)
AC  
(最初)
実行時間 -
コード長 682 bytes
コンパイル時間 2,088 ms
コンパイル使用メモリ 162,316 KB
実行使用メモリ 6,824 KB
最終ジャッジ日時 2025-01-28 03:50:04
合計ジャッジ時間 2,698 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample WA * 3
other WA * 25
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:30:16: warning: ‘ans’ may be used uninitialized [-Wmaybe-uninitialized]
   30 |             ans++;
      |             ~~~^~
main.cpp:18:12: note: ‘ans’ was declared here
   18 |     int K, ans;
      |            ^~~

ソースコード

diff #

/**
 *    author:  ytsmash
 *    created: 14.08.2021 09:15:35
 **/

#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define all(x) x.begin(), x.end()
const long double EPS = 1e-10;
const long long INF = 1e18;
const long double PI = acos(-1.0L);
using P = pair<int, int>;

int main() {
    int K, ans;
    cin >> K;
    vector<int> a(8);
    iota(all(a), 1);

    do {
        int check = 0;
        rep(i, 8) {
            check *= 10;
            check += a[i];
        }
        if (check % K == 0) {
            ans++;
        }
    } while (next_permutation(all(a)));

    cout << ans << "\n";
    return 0;
}
0