답안 #742488

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
742488 2023-05-16T10:15:43 Z irmuun Brunhilda’s Birthday (BOI13_brunhilda) C++17
컴파일 오류
0 ms 0 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()

const int MAX=1e9;

int main(){
    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    int m,q;
    cin>>m>>q;
    int p[m+5];
    for(int i=1;i<=m;i++){
        cin>>p[i];
    }
    sort(p+1,p+m+1);
    if(q==1){
        cin>>n;
        int ans=0;
        while(n>0){
            int nxt=n;
            for(int i=1;i<=m;i++){
                nxt=min(nxt,n/p[i]*p[i]);
            }
            if(nxt==n){
                cout<<"oo";
                return 0;
            }
            ans++;
            n=nxt;
        }
        cout<<ans;
        return 0;
    }
    int ans[10005];
    ans[0]=0;
    for(int i=1;i<p[m];i++){
        ans[i]=1;
    }
    for(int i=p[m];i<=10000;i++){
        ans[i]=MAX;
        for(int j=1;j<=m;j++){
            ans[i]=min(ans[i],ans[i/p[j]*p[j]]+1);
        }
    }
    while(q--){
        int n;
        cin>>n;
        if(ans[n]==MAX){
            cout<<"oo\n";
        }
        else{
            cout<<ans[n]<<"\n";
        }
    }
}

Compilation message

brunhilda.cpp: In function 'int main()':
brunhilda.cpp:23:14: error: 'n' was not declared in this scope
   23 |         cin>>n;
      |              ^