Submission #106108

#TimeUsernameProblemLanguageResultExecution timeMemory
106108sofhiasouzaSequence (BOI14_sequence)C++14
0 / 100
4 ms384 KiB
#include <bits/stdc++.h>
using namespace std;
int main()
{
	int k, a;
	string s;
	cin >> k;
	for(int i = 0 ; i < k ; i++) cin >> a;
	if(k == 1 and a != 0) cout << a << endl;
	else if(a == 0)
	{
		k--;
		stringstream ans;
		ans << k;
		ans >> s;
		if(k == 0) cout << 10 << endl;
		else cout << pow(10, s.size()+1) << endl;
	}
	else if(a == 9)
	{
		k--;
		stringstream ans;
		ans << k;
		ans >> s;
		int t = pow(10, s.size()-2);
		if(t == 1) t = 0;
		if(s.size() == 1) cout << 89 << endl;
		else if(t+1 + pow(10, s.size()-1) > k) cout << pow(10, s.size()-1)*9 - t-1 << endl; 
		else cout << pow(10, s.size())*9 - pow(10, s.size()-1)-1 << endl;
	}
	else
	{
		stringstream ans;
		ans << k;
		ans >> s;
		cout << pow(10, s.size())*a << endl;
	}
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...