답안 #134509

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
134509 2019-07-23T00:32:22 Z degelo Brunhilda’s Birthday (BOI13_brunhilda) C++17
컴파일 오류
0 ms 0 KB
#define inf 1000000000
#define maxn 20000
using namespace std;
long long int prod=1;
int m,q;
int p[maxn];
int dp[maxn];
int DP(int k){
	if(dp[k]!=0) return dp[k];
	if(k==0) return 0;
	if(k<p[m-1]) return 1;
	int resp=inf;
	for(int i=0;i<m;i++){
		if(k%p[i]==0) continue;
		resp=min(resp,DP((k/p[i])*p[i])+1);
	}
	return resp;
}
int main(){
	scanf("%d %d",&m,&q); 
	for(int i=0;i<m;i++){
		scanf("%d",&p[i]);
	}
	for(int i=0;i<m;i++){
		prod*=p[i];
		if(prod>maxn) break;
	}
	for(int i=0;i<q;i++){
		int n;
		scanf("%d",&n);
		if(n>=prod) printf("oo\n");
		else printf("%d\n",DP(n));
	}
}
int main(){
	scanf("%d %d",&m,&q); 
	for(int i=0;i<m;i++){
		scanf("%d",&p[i]);
		
	}
	for(int i=0;i<m;i++){
		prod*=p[i];
		if(prod>maxn) break;
	}
	for(int i=0;i<q;i++){
		int n;
		scanf("%d",&n);
		if(n>=prod) printf("oo\n");
		else printf("%d\n",DP(n));
	}
}

Compilation message

brunhilda.cpp: In function 'int DP(int)':
brunhilda.cpp:15:8: error: 'min' was not declared in this scope
   resp=min(resp,DP((k/p[i])*p[i])+1);
        ^~~
brunhilda.cpp:15:8: note: suggested alternative: 'maxn'
   resp=min(resp,DP((k/p[i])*p[i])+1);
        ^~~
        maxn
brunhilda.cpp: In function 'int main()':
brunhilda.cpp:20:2: error: 'scanf' was not declared in this scope
  scanf("%d %d",&m,&q); 
  ^~~~~
brunhilda.cpp:31:15: error: 'printf' was not declared in this scope
   if(n>=prod) printf("oo\n");
               ^~~~~~
brunhilda.cpp:31:15: note: suggested alternative: 'inf'
   if(n>=prod) printf("oo\n");
               ^~~~~~
               inf
brunhilda.cpp:32:8: error: 'printf' was not declared in this scope
   else printf("%d\n",DP(n));
        ^~~~~~
brunhilda.cpp:32:8: note: suggested alternative: 'inf'
   else printf("%d\n",DP(n));
        ^~~~~~
        inf
brunhilda.cpp: In function 'int main()':
brunhilda.cpp:35:5: error: redefinition of 'int main()'
 int main(){
     ^~~~
brunhilda.cpp:19:5: note: 'int main()' previously defined here
 int main(){
     ^~~~
brunhilda.cpp:36:2: error: 'scanf' was not declared in this scope
  scanf("%d %d",&m,&q); 
  ^~~~~
brunhilda.cpp:48:15: error: 'printf' was not declared in this scope
   if(n>=prod) printf("oo\n");
               ^~~~~~
brunhilda.cpp:48:15: note: suggested alternative: 'inf'
   if(n>=prod) printf("oo\n");
               ^~~~~~
               inf
brunhilda.cpp:49:8: error: 'printf' was not declared in this scope
   else printf("%d\n",DP(n));
        ^~~~~~
brunhilda.cpp:49:8: note: suggested alternative: 'inf'
   else printf("%d\n",DP(n));
        ^~~~~~
        inf