제출 #493717

#제출 시각아이디문제언어결과실행 시간메모리
493717_Monkey_Brunhilda’s Birthday (BOI13_brunhilda)C++17
컴파일 에러
0 ms0 KiB
#include<bits/stdc++.h> using namespace std; #define ll long long #define el '\n' #define ld long double const int maxn=1e5+1,nn=1e7+1; void amax(int &x,int y){if(y>x)x=y;} int a[maxn],n,m,q,p,oo,ans,k,f[nn]; int t; bool ok; void check(){ t=1; ok=0; for(int i=0;i<m;++i){ k=t*a[i]; if(t*a[i]<t || t*a[i]>oo || k/a[i]!=t){ ok=1; return; } t=t*a[i]; } } int sol(int z){ if(f[z]>=0) return f[z]; int ma=0; f[z]=sol(z-ut[z])+1; return f[z]; } int main(){ ios_base::sync_with_stdio(0);cin.tie(0); cin >> m >> q; for(int i=0;i<m;++i) cin >> a[i]; sort(a+0,a+m); for(int i=0;i<m;++i) for(int j=a[i]-1;j<nn;j+=a[i]) ut[j]=a[i]-1; for(int i=nn-2;i>0;--i) amax(ut[i],ut[i+1]-1); memset(f,-1,sizeof f); f[0]=0; oo=1e7; check(); while(q--){ cin >> n; if(ok){ cout << sol(n); } else { if(n>=t){ cout << "oo"; } else { cout << sol(n); } } cout << el; } return 0; }

컴파일 시 표준 에러 (stderr) 메시지

brunhilda.cpp: In function 'int sol(int)':
brunhilda.cpp:27:16: error: 'ut' was not declared in this scope; did you mean 't'?
   27 |     f[z]=sol(z-ut[z])+1;
      |                ^~
      |                t
brunhilda.cpp:26:9: warning: unused variable 'ma' [-Wunused-variable]
   26 |     int ma=0;
      |         ^~
brunhilda.cpp: In function 'int main()':
brunhilda.cpp:36:40: error: 'ut' was not declared in this scope; did you mean 't'?
   36 |         for(int j=a[i]-1;j<nn;j+=a[i]) ut[j]=a[i]-1;
      |                                        ^~
      |                                        t
brunhilda.cpp:37:34: error: 'ut' was not declared in this scope; did you mean 't'?
   37 |     for(int i=nn-2;i>0;--i) amax(ut[i],ut[i+1]-1);
      |                                  ^~
      |                                  t