Submission #41356

# Submission time Handle Problem Language Result Execution time Memory
41356 2018-02-16T18:55:43 Z gabrielsimoes Sequence (BOI14_sequence) C++14
0 / 100
3 ms 632 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) {
      printf("8");
      cur = cur * 10 + 1;
    }

    printf("9\n");
  }

  if (x == 0) {
    printf("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);
                    ^
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 248 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 480 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 480 KB Output is correct
2 Incorrect 3 ms 480 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 632 KB Output isn't correct
2 Halted 0 ms 0 KB -