#include<bits/stdc++.h>
#define ll long long
#define vl vector<ll>
#define sl set<ll>
#define all(v) v.begin(), v.end()
#define pb push_back
#define s second
#define f first
#define pll pair<ll, ll>
#define pii pair<int, int>
using namespace std;
ll f1(ll n)
{
ll y, k = 0;
y = n;
while(n % 2 == 0)
{
k++;
n /= 2;
}
return y / n;
}
ll f2(ll n)
{
while(n % 2 == 0)
n /= 2;
return n;
}
int main()
{
ll n, i, j, q, x;
cin >> n;
vl v(n);
for(ll&h : v) cin >> h;
vl v1;
for(i = 0; i < n; i++)
{
if(v[i] % 2 == 1) v1.pb(v[i]);
else
{
for(j = 0; j < f1(v[i]); j++) v1.pb(f2(v[i]));
}
}
/*for(ll&h : v1)
cout << h << ' ';
cout << "\n";*/
cin >> q;
while(q--)
{
cin >> x;
cout << v1[x-1] << "\n";
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
95 ms |
6588 KB |
Output is correct |
4 |
Correct |
236 ms |
3012 KB |
Output is correct |
5 |
Correct |
349 ms |
7284 KB |
Output is correct |
6 |
Correct |
178 ms |
10444 KB |
Output is correct |
7 |
Correct |
364 ms |
10604 KB |
Output is correct |
8 |
Correct |
349 ms |
18824 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Execution timed out |
2086 ms |
263172 KB |
Time limit exceeded |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
95 ms |
6588 KB |
Output is correct |
4 |
Correct |
236 ms |
3012 KB |
Output is correct |
5 |
Correct |
349 ms |
7284 KB |
Output is correct |
6 |
Correct |
178 ms |
10444 KB |
Output is correct |
7 |
Correct |
364 ms |
10604 KB |
Output is correct |
8 |
Correct |
349 ms |
18824 KB |
Output is correct |
9 |
Correct |
1 ms |
212 KB |
Output is correct |
10 |
Correct |
1 ms |
212 KB |
Output is correct |
11 |
Execution timed out |
2086 ms |
263172 KB |
Time limit exceeded |
12 |
Halted |
0 ms |
0 KB |
- |