#include "bits/stdc++.h"
using namespace std;
void abc() {cout << endl;}
template <typename T, typename ...U> void abc(T a, U ...b) {
cout << a << ' ', abc(b...);
}
template <typename T> void printv(T l, T r) {
while (l != r) cout << *l << " \n"[++l == r];
}
template <typename A, typename B> istream& operator >> (istream& o, pair<A, B> &a) {
return o >> a.first >> a.second;
}
template <typename A, typename B> ostream& operator << (ostream& o, pair<A, B> a) {
return o << '(' << a.first << ", " << a.second << ')';
}
template <typename T> ostream& operator << (ostream& o, vector<T> a) {
bool is = false;
for (T i : a) {o << (is ? ' ' : '{'), is = true, o << i;}
return o << '}';
}
#ifdef local
#define test(args...) abc("[" + string(#args) + "]", args)
#else
#define test(args...) void(0)
#endif
using ll = long long;
ll powers[51];
int main() {
ios_base::sync_with_stdio(0);
cin.tie(0); cout.tie(0);
// freopen("", "r", stdin);
// freopen("", "w", stdout);
int n; cin >> n;
powers[0] = 1;
for (int i = 1; i <= 50; i++) {
powers[i] = 2 * powers[i-1];
}
vector<ll> stuff;
vector<ll> orig;
for (int i = 0; i < n; i++) {
ll len; cin >> len;
orig.push_back(len);
ll lpower = 0;
for (int j = 50; j >= 0;j --) {
if (len % powers[j] == 0) {
lpower = powers[j];
break;
}
}
stuff.push_back(lpower);
}
vector<ll> curstuff(stuff.size());
for (int i = 0; i < stuff.size(); i++) {
if (i == 0) curstuff[i] = stuff[i];
else curstuff[i] = curstuff[i-1] + stuff[i];
// cout << curstuff[i] << endl;
}
int q; cin >> q;
while (q--) {
ll fl; cin >> fl;
int idx = lower_bound(curstuff.begin(), curstuff.end(), fl) - curstuff.begin();
cout << orig[idx] / stuff[idx] << "\n";
}
}
Compilation message
Main.cpp: In function 'int main()':
Main.cpp:64:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
64 | for (int i = 0; i < stuff.size(); i++) {
| ~~^~~~~~~~~~~~~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
66 ms |
5684 KB |
Output is correct |
4 |
Correct |
38 ms |
2876 KB |
Output is correct |
5 |
Correct |
93 ms |
7260 KB |
Output is correct |
6 |
Correct |
68 ms |
5556 KB |
Output is correct |
7 |
Correct |
96 ms |
7308 KB |
Output is correct |
8 |
Correct |
94 ms |
7384 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
320 KB |
Output is correct |
3 |
Correct |
0 ms |
212 KB |
Output is correct |
4 |
Correct |
0 ms |
212 KB |
Output is correct |
5 |
Correct |
0 ms |
212 KB |
Output is correct |
6 |
Correct |
1 ms |
328 KB |
Output is correct |
7 |
Correct |
1 ms |
320 KB |
Output is correct |
8 |
Correct |
1 ms |
340 KB |
Output is correct |
9 |
Correct |
1 ms |
324 KB |
Output is correct |
10 |
Correct |
1 ms |
212 KB |
Output is correct |
11 |
Correct |
1 ms |
340 KB |
Output is correct |
12 |
Correct |
1 ms |
340 KB |
Output is correct |
13 |
Correct |
1 ms |
340 KB |
Output is correct |
14 |
Correct |
1 ms |
332 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
66 ms |
5684 KB |
Output is correct |
4 |
Correct |
38 ms |
2876 KB |
Output is correct |
5 |
Correct |
93 ms |
7260 KB |
Output is correct |
6 |
Correct |
68 ms |
5556 KB |
Output is correct |
7 |
Correct |
96 ms |
7308 KB |
Output is correct |
8 |
Correct |
94 ms |
7384 KB |
Output is correct |
9 |
Correct |
1 ms |
212 KB |
Output is correct |
10 |
Correct |
0 ms |
320 KB |
Output is correct |
11 |
Correct |
0 ms |
212 KB |
Output is correct |
12 |
Correct |
0 ms |
212 KB |
Output is correct |
13 |
Correct |
0 ms |
212 KB |
Output is correct |
14 |
Correct |
1 ms |
328 KB |
Output is correct |
15 |
Correct |
1 ms |
320 KB |
Output is correct |
16 |
Correct |
1 ms |
340 KB |
Output is correct |
17 |
Correct |
1 ms |
324 KB |
Output is correct |
18 |
Correct |
1 ms |
212 KB |
Output is correct |
19 |
Correct |
1 ms |
340 KB |
Output is correct |
20 |
Correct |
1 ms |
340 KB |
Output is correct |
21 |
Correct |
1 ms |
340 KB |
Output is correct |
22 |
Correct |
1 ms |
332 KB |
Output is correct |
23 |
Correct |
35 ms |
3296 KB |
Output is correct |
24 |
Correct |
80 ms |
6476 KB |
Output is correct |
25 |
Correct |
120 ms |
10564 KB |
Output is correct |
26 |
Correct |
66 ms |
6804 KB |
Output is correct |
27 |
Correct |
65 ms |
6928 KB |
Output is correct |
28 |
Correct |
120 ms |
11024 KB |
Output is correct |
29 |
Correct |
85 ms |
10500 KB |
Output is correct |
30 |
Correct |
41 ms |
3912 KB |
Output is correct |
31 |
Correct |
104 ms |
10960 KB |
Output is correct |