제출 #105653

#제출 시각아이디문제언어결과실행 시간메모리
105653luciocf수열 (BOI14_sequence)C++14
9 / 100
8 ms384 KiB
#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] == 0) { for (long long i = 1; i <= 100000000000ll; i++); return 0; } if (a[0] == 9) { solve_9(); return 0; } int x = 1; for (int i = 0; i <= 20; i++) { if (a[i] == 0) { int val = x*10-1; val /= 9; if (val >= n) { printf("10"); for (int j = 1; j <= i; j++) printf("0\n"); printf("\n"); return 0; } } else if (x >= n) { printf("%d", a[0]); for (int j = 1; j <= i; j++) printf("0"); printf("\n"); return 0; } x *= 10; } }

컴파일 시 표준 에러 (stderr) 메시지

sequence.cpp: In function 'int main()':
sequence.cpp:66:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d", &n);
   ~~~~~^~~~~~~~~~
sequence.cpp:69:9: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
    scanf("%d", &a[i]);
    ~~~~~^~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...