Submission #77371

#TimeUsernameProblemLanguageResultExecution timeMemory
77371xiaowuc1Brunhilda’s Birthday (BOI13_brunhilda)C++14
100 / 100
69 ms39564 KiB
#include <bits/stdc++.h> /* unsigned seed1 = std::chrono::system_clock::now().time_since_epoch().count(); mt19937 g1.seed(seed1); ios_base::sync_with_stdio(false); cin.tie(NULL); */ using namespace std; const double PI = 2 * acos(0); typedef long long ll; typedef unsigned long long ull; typedef pair<int, int> pii; typedef pair<ll, ll> pll; typedef long double ld; typedef vector<vector<ll>> matrix; int primes[100000]; int thresh[10000000]; int main() { int n; int q; scanf("%d%d", &n, &q); for(int i = n-1; i >= 0; i--) { scanf("%d", &primes[i]); } thresh[1] = primes[0]-1; int ans = 2; while(thresh[ans-1] <= 10000000) { int last = thresh[ans-1]; int best = last; for(int i = 0; i < n; i++) { if((last+1)%primes[i] == 0) continue; int t = last - (last) % primes[i] + primes[i] - 1; if(t > best) { best = t; } if(last + primes[i] - 1 <= best) break; } if(last == best) break; thresh[ans++] = best; last = best; } ans--; while(q--) { int goal; scanf("%d", &goal); if(goal > thresh[ans]) { printf("oo\n"); } else { int lhs = 1; int rhs = ans; while(lhs != rhs) { int mid = (lhs+rhs)/2; if(thresh[mid] < goal) lhs = mid+1; else rhs = mid; } printf("%d\n", lhs); } } }

Compilation message (stderr)

brunhilda.cpp: In function 'int main()':
brunhilda.cpp:27:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d%d", &n, &q);
   ~~~~~^~~~~~~~~~~~~~~~
brunhilda.cpp:29:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d", &primes[i]);
     ~~~~~^~~~~~~~~~~~~~~~~~
brunhilda.cpp:51:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d", &goal);
     ~~~~~^~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...