Submission #31874

#TimeUsernameProblemLanguageResultExecution timeMemory
31874Dat160601Brunhilda’s Birthday (BOI13_brunhilda)C++14
100 / 100
489 ms80532 KiB
#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)

brunhilda.cpp: In function 'int main()':
brunhilda.cpp:13:25: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d %d",&m,&q);
                         ^
brunhilda.cpp:15:27: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%d",&pr[i]);
                           ^
brunhilda.cpp:26:23: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%d",&x);
                       ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...