제출 #1126535

#제출 시각아이디문제언어결과실행 시간메모리
1126535AgageldiBrunhilda’s Birthday (BOI13_brunhilda)C++20
97.14 / 100
1100 ms79584 KiB
#include <bits/stdc++.h> using namespace std; #define ll long long #define ff first #define ss second #define pb push_back #define sz(s) (int)s.size() #define N 20000005 ll n, m, q, a[N], ad[N], t; int main () { ios::sync_with_stdio(0);cin.tie(0); cin >> m >> q; for(int i = 1;i<=m;i++){ cin >> a[i]; for(int j = a[i]; j <= 1e7 + 1; j += a[i]) { ad[j - 1] = max(ad[j - 1], a[i] - 1); } ad[10000000] = max(ad[10000000],(10000000%a[i])); } for(int i = 1e7; i >= 1; i--) { ad[i] = max(ad[i],ad[i+1] - 1); } for(int i = 1; i <= q; i++) { int x, cnt = 0; cin >> x; bool tr = 0; while(x > 0) { t = x; x -= ad[x]; cnt++; if(t == x) { tr = 1; break; } } if(tr) { cout << "oo\n"; continue; } cout << cnt << '\n'; } }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...