Submission #3767634


Source Code Expand

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const ll MOD = 1000000007;
const int IINF = INT_MAX;
const ll LLINF = LLONG_MAX;
const int MAX_N = int(1e5 + 5);
const double EPS = 1e-10;
const int di[] = {0, 1, 0, -1}, dj[] = {1, 0, -1, 0};
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define SORT(v) sort((v).begin(), (v).end())
#define ALL(v) (v).begin(), (v).end()

int main() {
    int n, k, ans;
    bool ok[10];
    cin >> n >> k;
    REP(i,10)ok[i] = true;
    REP(i,k){
        int d;
        cin >> d;
        ok[d] = false;
    }
    ans = n;
    while(1){
        bool f = true;
        int tmp = ans;
        while(tmp>0){
            f &= ok[tmp%10];
            tmp /=10;
        }
        if(f){
            cout << ans << endl;
            break;
        }
        else{
            ans++;
        }
    }
    return 0;
}

Submission Info

Submission Time
Task C - Iroha's Obsession
User shinchan
Language C++14 (GCC 5.4.1)
Score 300
Code Size 975 Byte
Status AC
Exec Time 2 ms
Memory 256 KB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 300 / 300
Status AC
AC × 10
Set Name Test Cases
Sample
All subtask0_sample_01.txt, subtask0_sample_02.txt, subtask1_X_01.txt, subtask1_X_02.txt, subtask1_X_03.txt, subtask1_X_04.txt, subtask1_X_05.txt, subtask1_X_06.txt, subtask1_X_07.txt, subtask1_X_08.txt
Case Name Status Exec Time Memory
subtask0_sample_01.txt AC 1 ms 256 KB
subtask0_sample_02.txt AC 1 ms 256 KB
subtask1_X_01.txt AC 1 ms 256 KB
subtask1_X_02.txt AC 2 ms 256 KB
subtask1_X_03.txt AC 1 ms 256 KB
subtask1_X_04.txt AC 1 ms 256 KB
subtask1_X_05.txt AC 1 ms 256 KB
subtask1_X_06.txt AC 1 ms 256 KB
subtask1_X_07.txt AC 1 ms 256 KB
subtask1_X_08.txt AC 1 ms 256 KB