# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
631376 | anhduc2701 | Brunhilda’s Birthday (BOI13_brunhilda) | C++17 | 571 ms | 157352 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#define int long long
using namespace std;
const int maxn = 2e7 + 10;
const int INF = 1e10;
int dp[maxn];
int n, m;
signed main()
{
cin.tie(0),cout.tie(0)->sync_with_stdio;
cin >> n >> m;
for (int i = 1; i <= n; i++)
{
int p;
cin >> p;
for (int j = p - 1; j < maxn; j += p)
{
dp[j] = p - 1;
}
}
for (int i = maxn - 2; i > 0; i--)
{
dp[i] = max(dp[i + 1] - 1, dp[i]);
}
for (int i = 1; i < maxn; i++)
{
if (dp[i] > 0)
{
dp[i] = dp[i - dp[i]] + 1;
}
else
{
dp[i] = INF;
}
}
for (int i = 1; i <= m; i++)
{
int q;
cin >> q;
if(dp[q]>=INF){
cout<<"oo"<<'\n';
}
else{
cout<<dp[q]<<"\n";
}
}
}
컴파일 시 표준 에러 (stderr) 메시지
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |