제출 #1125885

#제출 시각아이디문제언어결과실행 시간메모리
1125885AgageldiBrunhilda’s Birthday (BOI13_brunhilda)C++20
0 / 100
1095 ms63676 KiB
#include <bits/stdc++.h> using namespace std; #define ll long long #define N 4000000 #define ff first #define ss second #define pb push_back #define sz(s) (int)s.size() ll n, m, q, vis[N], p, vip[N]; vector <ll> a; int main () { ios::sync_with_stdio(0);cin.tie(0); cin >> m >> q; for(ll i = 1;i<=m;i++) { ll x; cin >> x; if(vip[x]) continue; vip[x] = 1; for(ll j = x; j <= 1e5; j += x) { vis[j]++; } a.pb(x); } for(ll j = 2; j <= 1e5; j++) { if(vis[j] == m) { p = j; break; } } sort(a.rbegin(),a.rend()); for(int j = 1; j <= q; j++) { ll x, cnt = 0, tr = 0; cin >> x; if(x % p == 0) { cout << "oo\n"; continue; } while(x) { if(a[0] > x) { cnt++; break; } ll mx = INT_MAX; for(auto i : a) { if(mx > (x / i) * i) mx = (x / i) * i; if(i - 1 <= x - mx) break; } x = mx; cnt++; } if(!tr)cout << cnt << '\n'; } }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...