제출 #283207

#제출 시각아이디문제언어결과실행 시간메모리
283207Atill83Brunhilda’s Birthday (BOI13_brunhilda)C++14
5.87 / 100
43 ms1400 KiB
#include <bits/stdc++.h> #define ff first #define ss second #define endl '\n' using namespace std; const long long INF = (long long) 1e18; const int mod = (int) 1e9+7; const int MAXN = (int) 3e5+5; typedef long long ll; typedef unsigned long long ull; typedef pair<int,int> pii; typedef pair<ll,ll> pll; ll m, q; ll p[MAXN]; bool check(int n){ for(int i = 0; i < (1<<m); i++){ int cur = n; for(int j = m - 1; j >= 0; j--){ if((1<<j)&i){ cur = cur - cur % p[j]; } } if(cur < p[m - 1]) return 1; } return 0; } int main(){ ios_base::sync_with_stdio(false); cin.tie(nullptr);cout.tie(nullptr); #ifdef Local freopen("C:/Users/Admin/Desktop/Yazilim/C/IO/int.txt","r",stdin); freopen("C:/Users/Admin/Desktop/Yazilim/C/IO/out.txt","w",stdout); #endif cin>>m>>q; for(int i = 0; i < m; i++){ cin>>p[i]; } for(int i = 0; i < q; i++){ int n; cin>>n; if(p[m - 1] > n){ cout<<1<<endl; }else{ if(m <= 9 && check(n) == 0){ cout<<"oo\n"; }else{ cout<<(n / p[m - 1] + 1)*2 - 1<<endl; } } } #ifdef Local cout<<endl<<fixed<<setprecision(2)<<1000.0 * clock() / CLOCKS_PER_SEC<< " milliseconds "; #endif }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...