Submission #421931

# Submission time Handle Problem Language Result Execution time Memory
421931 2021-06-09T13:54:43 Z MetalPower Sequence (BOI14_sequence) C++14
Compilation error
0 ms 0 KB
#include <bits/stdc++.h>
using namespace std;

const int MX = 1e5 + 10, num = 1e4;
int K, arr[MX];

inline int check(int a, const int& b){
	while(a){
		if(a % 10 == b) return true;
		a /= 10;
	}
	return false;
}

inline void chmin(long long& a, long long b){
	if(b < a) a = b;
}

inline void solve_sub3(){
	ll size = N - 1, calc = 1, l = 0;

	if(arr[0] == 0){
		while(size >= calc){
			size -= calc;
			calc = (calc << 3) + (calc << 1);
			l++;
		}
		cout << "10";
		for(int i = 1; i <= l; i++) cout << "0";
	}else if(arr[0] == 9){
		while(size >= calc){
			size -= calc;
			calc = (calc << 3) + (calc << 1);
			l++;
		}
		for(int i = 1; i <= l; i++) cout << "8";
		cout << "9";
	}else{
		while(size){
			size /= 10; l++;
		}
		cout << arr[0];
		for(int i = 1; i <= l; i++) cout << "0";
	}

	cout << '\n';
}

bool vis[10];

int main(){
	ios_base::sync_with_stdio(0); cin.tie(NULL); cout.tie(NULL);

	cin >> K;

	bool eq = true;

	for(int i = 0; i < K; i++){
		cin >> arr[i]; if(arr[i] != arr[0]) eq = false;
	}

	if(eq){
		solve_sub3();
	}else{

		long long mn = 1e18;

		for(int N = 1; N < num; N++){
			bool pos = true;
			for(int i = 0; i < K; i++){
				if(!check(N + i, arr[i])){
					pos = false; break;
				}
			}
			if(pos) chmin(mn, (long long) N);
		}

		cout << mn << '\n';
	}
}

Compilation message

sequence.cpp: In function 'void solve_sub3()':
sequence.cpp:20:2: error: 'll' was not declared in this scope
   20 |  ll size = N - 1, calc = 1, l = 0;
      |  ^~
sequence.cpp:23:9: error: 'size' was not declared in this scope; did you mean 'dysize'?
   23 |   while(size >= calc){
      |         ^~~~
      |         dysize
sequence.cpp:23:17: error: 'calc' was not declared in this scope
   23 |   while(size >= calc){
      |                 ^~~~
sequence.cpp:26:4: error: 'l' was not declared in this scope
   26 |    l++;
      |    ^
sequence.cpp:29:23: error: 'l' was not declared in this scope
   29 |   for(int i = 1; i <= l; i++) cout << "0";
      |                       ^
sequence.cpp:31:9: error: 'size' was not declared in this scope; did you mean 'dysize'?
   31 |   while(size >= calc){
      |         ^~~~
      |         dysize
sequence.cpp:31:17: error: 'calc' was not declared in this scope
   31 |   while(size >= calc){
      |                 ^~~~
sequence.cpp:34:4: error: 'l' was not declared in this scope
   34 |    l++;
      |    ^
sequence.cpp:36:23: error: 'l' was not declared in this scope
   36 |   for(int i = 1; i <= l; i++) cout << "8";
      |                       ^
sequence.cpp:39:9: error: 'size' was not declared in this scope; did you mean 'dysize'?
   39 |   while(size){
      |         ^~~~
      |         dysize
sequence.cpp:40:16: error: 'l' was not declared in this scope
   40 |    size /= 10; l++;
      |                ^
sequence.cpp:43:23: error: 'l' was not declared in this scope
   43 |   for(int i = 1; i <= l; i++) cout << "0";
      |                       ^