# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
106166 | sofhiasouza | Sequence (BOI14_sequence) | C++14 | 7 ms | 384 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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;
k--;
stringstream ans;
ans << k;
ans >> s;
if(k == 0 and a != 0) cout << a << endl;
else if(a == 0)
{
string ss;
stringstream aux;
aux << k-1;
aux >> ss;
if(k == 0) cout << 10 << endl;
else if(ss.size() != s.size()) cout << pow(10, s.size()) << endl;
else cout << pow(10, s.size()+1) << endl;
}
else if(a == 9)
{
int p = 0, p2 = 0;
p2 += pow(10, s.size() - 1);
for(int i = 2 ; i <= s.size() ; i++) p += pow(10, s.size() - i);
p2 += p;
if(s.size() == 1) cout << 89 << endl;
else if(p + pow(10, s.size()-1) > k) cout << pow(10, s.size()-1)*9 - p << endl;
else cout << pow(10, s.size())*9 - p2 << endl;
}
else cout << pow(10, s.size())*a << endl;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |