답안 #41357

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
41357 2018-02-16T19:02:23 Z gabrielsimoes 수열 (BOI14_sequence) C++14
9 / 100
96 ms 1004 KB
#include <bits/stdc++.h>
using namespace std;

bool test(int a, int b) {
  while (a > 0) {
    if (b == (a % 10))
      return true;
    else
      a /= 10;
  }

  return false;
}

int n;
vector<int> v;

int main() {
  scanf("%d", &n);
  for (int i = 0, a; i < n; i++) {
    scanf("%d", &a);
    v.push_back(a);
  }

  if (n <= 10000) {
    for (int ans = 1; ans <= 10000; ans++) {
      bool ok = true;
      for (int i = 0; i < n; i++) {
        if (!test(ans + i, v[i])) ok = false;
      }

      if (ok) {
        printf("%d\n", ans);
        return 0;
      }
    }
  }

  int x = v[0];

  if (x > 0 && x < 9) {
    printf("%d", x);
    int cur = 1;
    while (n >= cur + 1) {
      printf("0");
      cur *= 10;
    }
    printf("\n");
  }

  if (x == 9) {
    int cur = 1;
    while (n >= cur + 1) {
      printf("8");
      cur = cur * 10 + 1;
    }

    printf("9\n");
  }

  if (x == 0) {
    printf("10");
    if (n != 1) {
      int cur = 1;
      while (n >= cur) {
        printf("0");
        cur = cur * 10 + 1;
      }
    }
    printf("\n");
  }
}

Compilation message

sequence.cpp: In function 'int main()':
sequence.cpp:19:18: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d", &n);
                  ^
sequence.cpp:21:20: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d", &a);
                    ^
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 248 KB Output is correct
2 Correct 5 ms 352 KB Output is correct
3 Correct 1 ms 424 KB Output is correct
4 Correct 3 ms 496 KB Output is correct
5 Correct 2 ms 496 KB Output is correct
6 Correct 2 ms 496 KB Output is correct
7 Correct 2 ms 496 KB Output is correct
8 Correct 8 ms 512 KB Output is correct
9 Correct 1 ms 512 KB Output is correct
10 Correct 3 ms 512 KB Output is correct
11 Correct 3 ms 512 KB Output is correct
12 Correct 2 ms 512 KB Output is correct
13 Correct 2 ms 512 KB Output is correct
14 Correct 13 ms 512 KB Output is correct
15 Correct 13 ms 548 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 548 KB Output is correct
2 Correct 5 ms 548 KB Output is correct
3 Correct 1 ms 548 KB Output is correct
4 Correct 3 ms 548 KB Output is correct
5 Correct 2 ms 604 KB Output is correct
6 Correct 1 ms 616 KB Output is correct
7 Correct 79 ms 616 KB Output is correct
8 Correct 2 ms 616 KB Output is correct
9 Correct 8 ms 616 KB Output is correct
10 Correct 1 ms 616 KB Output is correct
11 Incorrect 96 ms 628 KB Output isn't correct
12 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 628 KB Output is correct
2 Correct 3 ms 628 KB Output is correct
3 Correct 3 ms 628 KB Output is correct
4 Incorrect 4 ms 628 KB Output isn't correct
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 628 KB Output is correct
2 Correct 5 ms 628 KB Output is correct
3 Correct 2 ms 628 KB Output is correct
4 Correct 2 ms 628 KB Output is correct
5 Incorrect 6 ms 1004 KB Output isn't correct
6 Halted 0 ms 0 KB -