Submission #483299

# Submission time Handle Problem Language Result Execution time Memory
483299 2021-10-28T14:46:28 Z ntabc05101 Brunhilda’s Birthday (BOI13_brunhilda) C++14
Compilation error
0 ms 0 KB
#include<bits/stdc++.h>
using namespace std;

const int mxN = 10000000;

int dp[mxN + 1], b[mxN + 1];

int main() {
	cin.tie(0)->sync_with_stdio(0);

	int m, Q; cin >> m >> Q;
	int prs[m];
	for (int i = 0; i < m; i++) {
		cin >> prs[i];
	}
	iota(b + 1, b + mxN + 1, 1);
	sort(prs, prs + m);
	int mn = mxN + 1;
	for (int i = 0; i < m; i++) {
		for (j = prs[i]; j <= mxN; j += prs[i]) {
			b[j - 1] = j - prs[i];
		}
		mn = min(mn, j - prs[i]);
	}

	for (int i = mxN; i; i--) {
		dp[i] = mxN + 1;
		mn = min(mn, b[i]);
		b[i] = mn;
	}
	for (int i = 1; i <= mxN; i++) {
		if (i == b[i]) {
			break;
		}
		dp[i] = dp[b[i]] + 1;
	}

	while (Q--) {
		int n; cin >> n;
		if (dp[n] == mxN + 1) {
			cout << "oo\n";
		}
		else {
			cout << dp[n] << "\n";
		}
	}

	return 0;
}

Compilation message

brunhilda.cpp: In function 'int main()':
brunhilda.cpp:20:8: error: 'j' was not declared in this scope
   20 |   for (j = prs[i]; j <= mxN; j += prs[i]) {
      |        ^
brunhilda.cpp:23:16: error: 'j' was not declared in this scope
   23 |   mn = min(mn, j - prs[i]);
      |                ^