# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
31874 | Dat160601 | Brunhilda’s Birthday (BOI13_brunhilda) | C++14 | 489 ms | 80532 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
const int MAX=1e7;
using namespace std;
int m,q,ans[MAX+7],pr[100007],dive[MAX+7],x;
void prep(){
for(int i=1;i<=m;i++){
for(int j=0;j<=MAX;j+=pr[i]){
dive[j]=pr[i];
}
}
}
int main(){
scanf("%d %d",&m,&q);
for(int i=1;i<=m;i++){
scanf("%d",&pr[i]);
}
prep();
int cnt=0;
ans[0]=1;
for(int i=1;i<=MAX;i++){
while(cnt<i && cnt+dive[cnt]-1<i) cnt++;
if(cnt==i) break;
ans[i]=ans[cnt]+1;
}
while(q--){
scanf("%d",&x);
if(ans[x]==0) printf("oo\n");
else printf("%d\n",ans[x]-1);
}
}
Compilation message (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... |