이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define ll long long
#define ff first
#define ss second
#define all(s) s.begin(),s.end()
int main(){
ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
ll k;
cin>>k;
ll b[k+5];
bool same=true;
for(ll i=0;i<k;i++){
cin>>b[i];
if(i>0){
same&=(b[i]==b[i-1]);
}
}
if(k<=1000){
for(ll i=1;i<=1000;i++){
ll cnt=0;
for(ll j=0;j<k;j++){
ll n=i+j;
bool ok=false;
while(n>0){
if(n%10==b[j]){
ok=true;
break;
}
n/=10;
}
cnt+=(ok==true);
}
if(cnt==k){
cout<<i;
return 0;
}
}
}
ll cur=0;
for(ll i=1;i<=1100000;i++){
ll add=0;
ll x=i;
while(x>0){
if(x%10==b[0]){
add=1;
break;
}
x/=10;
}
if(add==0){
cur=0;
}
else{
cur++;
if(cur==k){
cout<<i-k+1;
return 0;
}
}
}
}
# | 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... |