답안 #751057

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
751057 2023-05-31T02:55:51 Z irmuun 수열 (BOI14_sequence) C++17
0 / 100
1 ms 340 KB
#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 ok=true;
    for(ll i=1;i<=k;i++){
        cin>>b[i];
        if(i>1){
            ok&=(b[i]==b[i-1]);
        }
    }
    if(ok==true){
        if(1<b[1]&&b[1]<9){
            ll ans=b[1];
            ll cur=1;
            while(cur=k){
                cur*=10;
                ans*=10;
            }
            cout<<ans;
        }
        if(b[1]==0){
            ll cur=1;
            ll ans=10;
            while(cur<k){
                cur=cur*10+1;
                ans*=10;
            }
            cout<<ans;
        }
        if(b[1]==9){
            if(k==1){
                cout<<9;
                return 0;
            }
            ll ans=89;
            ll cur=11;
            while(cur<k){
                ans*=10;
                cur=cur*10+1;
            }
            cout<<ans;
        }
        return 0;
    }
    else{
        for(int i=1;i<=1000;i++){
            int cnt=0;
            for(int j=0;j<k;j++){
                int 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;
            }
        }
    }
}

Compilation message

sequence.cpp: In function 'int main()':
sequence.cpp:27:22: warning: suggest parentheses around assignment used as truth value [-Wparentheses]
   27 |             while(cur=k){
      |                   ~~~^~
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 316 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Incorrect 1 ms 340 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 320 KB Output isn't correct
2 Halted 0 ms 0 KB -