제출 #60816

#제출 시각아이디문제언어결과실행 시간메모리
60816RezwanArefin01Brunhilda’s Birthday (BOI13_brunhilda)C++17
100 / 100
632 ms79524 KiB
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef pair<int, int> ii; 

const int N = 1e7 + 1; 
const int M = 1e5 + 1; 
int m, q, d[N], p, dp[N]; 

int main(int argc, char const *argv[]) {
#ifdef LOCAL
	freopen("in", "r", stdin);
#endif
	memset(dp, 127, sizeof dp); 
	scanf("%d %d", &m, &q); 
	for(int i = 0; i < m; i++) { 
		scanf("%d", &p); 
		for(int j = 0; j < N; j += p) d[j] = p; 
	}	
	int prv = 0; dp[0] = 0; 
	for(int i = 1; i < N; i++) {
		while(prv < i) {
			if(!d[prv] || prv + d[prv] <= i) ++prv; 
			else break; 
		}
		if(prv == i) break; 
		dp[i] = dp[prv] + 1; 
	}
	while(q--) {
		int x; scanf("%d", &x);
		if(dp[x] >= 2139062143) puts("oo"); 
		else printf("%d\n", dp[x]);
	}
}

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

brunhilda.cpp: In function 'int main(int, const char**)':
brunhilda.cpp:16:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d %d", &m, &q); 
  ~~~~~^~~~~~~~~~~~~~~~~
brunhilda.cpp:18:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d", &p); 
   ~~~~~^~~~~~~~~~
brunhilda.cpp:31:15: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   int x; scanf("%d", &x);
          ~~~~~^~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...