# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
105636 | 2019-04-13T18:51:53 Z | luciocf | 수열 (BOI14_sequence) | C++14 | 9 ms | 384 KB |
#include <bits/stdc++.h> using namespace std; const int maxn = 1e3+10; int n; int a[maxn]; int brute(void) { for (int j = 1; j <= 1000; j++) { int v = j; bool deu = 1; for (int i = 0; i < n; i++) { int aux = v; bool ok = 0; while (aux > 0) { if (aux%10 == a[i]) ok = 1; aux /= 10; } if (!ok) deu = 0; v++; } if (deu) return j; } return -1; } void solve_9(void) { if (n == 1) { printf("9\n"); return; } for (int i = 1; i <= n; i++) { int x = 1; for (int j = 1; j <= i; j++) x *= 10; x--; x /= 9; if (x >= n) { for (int j = 1; j < i; j++) printf("8"); printf("9\n"); return; } } } int main(void) { scanf("%d", &n); for (int i = 0; i < n; i++) scanf("%d", &a[i]); if (n <= 1000) { printf("%d\n", brute()); return 0; } if (a[0] == 9) { solve_9(); return 0; } int x = 1; for (int i = 0; i <= 20; i++) { if (x >= n) { if (a[0] == 0) printf("1"); printf("%d", a[0]); for (int j = 1; j <= i; j++) printf("0"); printf("\n"); return 0; } x *= 10; } }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 256 KB | Output is correct |
2 | Correct | 6 ms | 256 KB | Output is correct |
3 | Correct | 2 ms | 256 KB | Output is correct |
4 | Correct | 3 ms | 256 KB | Output is correct |
5 | Correct | 2 ms | 384 KB | Output is correct |
6 | Correct | 2 ms | 256 KB | Output is correct |
7 | Correct | 3 ms | 384 KB | Output is correct |
8 | Correct | 9 ms | 384 KB | Output is correct |
9 | Correct | 2 ms | 256 KB | Output is correct |
10 | Correct | 3 ms | 384 KB | Output is correct |
11 | Correct | 2 ms | 256 KB | Output is correct |
12 | Correct | 2 ms | 384 KB | Output is correct |
13 | Correct | 3 ms | 256 KB | Output is correct |
14 | Correct | 8 ms | 256 KB | Output is correct |
15 | Correct | 8 ms | 384 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 256 KB | Output is correct |
2 | Correct | 3 ms | 256 KB | Output is correct |
3 | Correct | 2 ms | 256 KB | Output is correct |
4 | Correct | 3 ms | 384 KB | Output is correct |
5 | Correct | 3 ms | 256 KB | Output is correct |
6 | Correct | 2 ms | 256 KB | Output is correct |
7 | Incorrect | 8 ms | 256 KB | Output isn't correct |
8 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 256 KB | Output is correct |
2 | Incorrect | 2 ms | 356 KB | Output isn't correct |
3 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 256 KB | Output is correct |
2 | Correct | 4 ms | 384 KB | Output is correct |
3 | Correct | 2 ms | 356 KB | Output is correct |
4 | Correct | 3 ms | 256 KB | Output is correct |
5 | Incorrect | 2 ms | 384 KB | Output isn't correct |
6 | Halted | 0 ms | 0 KB | - |