제출 #856575

#제출 시각아이디문제언어결과실행 시간메모리
856575ngjabachBrunhilda’s Birthday (BOI13_brunhilda)C++14
100 / 100
222 ms47956 KiB
// NgJaBach: Forever Meadow <3 #include<bits/stdc++.h> using namespace std; mt19937 rng(chrono::steady_clock::now().time_since_epoch().count()); typedef long long int ll; typedef unsigned long long ull; #define pb push_back #define pob pop_back #define mp make_pair #define upb upper_bound #define lwb lower_bound #define bend(a) a.begin(),a.end() #define rev(x) reverse(bend(x)) #define mset(a) memset(a, 0, sizeof(a)) #define fi first #define se second #define gcd __gcd #define getl(s) getline(cin, s); #define setpre(x) fixed << setprecision(x) #define endl '\n' const int N=12000000,M=1000000000; const ll INF=1e18+7; int dp[N+50]; int main(){ ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); // freopen(".inp","r",stdin); // freopen(".out","w",stdout); int n,q,a; cin>>n>>q; mset(dp); while(n--){ cin>>a; for(int i=a-1;i<=N;i+=a) dp[i]=max(dp[i],a-1); } for(int i=N;i>0;--i) dp[i]=max(dp[i],dp[i+1]-1); for(int i=1;i<=N;++i){ if(dp[i]>0) dp[i]=dp[i-dp[i]]+1; else dp[i]=M; } while(q--){ cin>>a; if(dp[a]>=M) cout<<"oo"; else cout<<dp[a]; cout<<endl; } return 0; } /* ==================================+ INPUT: | ------------------------------ | 2 2 2 3 5 6 ------------------------------ | ==================================+ OUTPUT: | ------------------------------ | ------------------------------ | ==================================+ */
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...