Submission #25866

#TimeUsernameProblemLanguageResultExecution timeMemory
25866gs14004Brunhilda’s Birthday (BOI13_brunhilda)C++11
76.03 / 100
1000 ms41080 KiB
#include <bits/stdc++.h> using namespace std; typedef long long lint; typedef pair<int, int> pi; const int mod = 1e9 + 7; int n, q; int nxt[10000005]; int main(){ scanf("%d %d",&n,&q); for(int i=1; i<=n; i++){ int x; scanf("%d",&x); for(int j=x; j-1<=10000000; j+=x){ nxt[j-1] = x-1; } } for(int i=10000000; i; i--) nxt[i] = max(nxt[i], nxt[i+1] - 1); while(q--){ int x; scanf("%d",&x); int cnt = 0; while(x > 0){ if(nxt[x] == 0){ puts("oo"); cnt = -1; break; } x -= nxt[x]; cnt++; } if(cnt >= 0) printf("%d\n", cnt); } }

Compilation message (stderr)

brunhilda.cpp: In function 'int main()':
brunhilda.cpp:11:22: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d %d",&n,&q);
                      ^
brunhilda.cpp:14:17: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d",&x);
                 ^
brunhilda.cpp:22:17: 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...