# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
243399 | Lawliet | Brunhilda’s Birthday (BOI13_brunhilda) | C++17 | 288 ms | 262148 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
const int MAXM = 100010;
const int MAXN = 10000010;
const int INF = 1000000010;
int m, q;
int v[MAXM];
int dp[MAXN];
vector<int> d[MAXN];
vector<int> multiples[MAXM];
int main()
{
scanf("%d %d",&m,&q);
for(int i = 1 ; i <= m ; i++)
scanf("%d",&v[i]);
for(int i = 1 ; i <= m ; i++)
{
for(int cur = v[i] ; cur < MAXN ; cur += v[i])
{
d[cur].push_back( i );
multiples[i].push_back( cur );
}
}
int mn = INF;
for(int i = 1 ; i <= m ; i++)
mn = min( mn , 10000000 - (10000000%v[i]) );
for(int i = MAXN - 1 ; i > 0 ; i--)
{
dp[i] = mn;
for(int j = 0 ; j < (int)d[i].size() ; j++)
{
int curPrime = d[i][j];
multiples[curPrime].pop_back();
mn = min( mn , multiples[curPrime].back() );
}
}
for(int i = 1 ; i < MAXN ; i++)
{
if( dp[i] == i ) dp[i] = INF;
else dp[i] = dp[ dp[i] ] + 1;
}
for(int i = 1 ; i <= q ; i++)
{
int p;
scanf("%d",&p);
if( dp[p] >= INF ) printf("oo\n");
else printf("%d\n",dp[p]);
}
}
컴파일 시 표준 에러 (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... |