#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define int long long
#define endl "\n"
int mod=1e9+7;
const int N=2e5+5;
template<class x>
using ordered_multiset = tree<x, null_type,less_equal<x>, rb_tree_tag,tree_order_statistics_node_update>;
int n;
vector<pair<int,int> > v;
void cl(int x) {
int idk=log2(x);
idk=pow(2,idk);
if (idk==x) {
v.push_back({x,1});
return;
}
if (x%2!=0) {
v.push_back({1,x});
return;
}
pair<int,int> gg={1e10,1e10};
int st=x;
if (st%2==0) st--;
for (int i=st;i>=1;i-=2) {
int j=x/i;
if (x%i==0 && x%j==0) {
if (i%2==0) gg={i,j};
else if (j%2==0) gg={j,i};
else gg={min(i,j),max(i,j)};
break;
}
}
v.push_back(gg);
}
signed main() {
ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
//freopen(".in", "r", stdin); freopen(".out", "w", stdout);
cin>>n;
for (int i=0;i<n;i++) {
int x; cin>>x;
cl(x);
}
pair<int,int> prfx[n+1];
for (int i=1;i<=n;i++) {
prfx[i].first=v[i-1].first+prfx[i-1].first;
prfx[i].second=v[i-1].second;
}
int q; cin>>q;
while (q--) {
int x; cin>>x;
pair<int,int> tmp={x,0};
int i=upper_bound(prfx+1,prfx+(n+1),tmp)-prfx+1;
i--;
cout<<prfx[i].second<<endl;
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Correct |
28 ms |
6448 KB |
Output is correct |
4 |
Correct |
31 ms |
2140 KB |
Output is correct |
5 |
Correct |
63 ms |
7168 KB |
Output is correct |
6 |
Correct |
38 ms |
5828 KB |
Output is correct |
7 |
Correct |
59 ms |
6980 KB |
Output is correct |
8 |
Correct |
59 ms |
7128 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
0 ms |
212 KB |
Output is correct |
4 |
Correct |
1924 ms |
300 KB |
Output is correct |
5 |
Correct |
0 ms |
212 KB |
Output is correct |
6 |
Execution timed out |
2072 ms |
212 KB |
Time limit exceeded |
7 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Correct |
28 ms |
6448 KB |
Output is correct |
4 |
Correct |
31 ms |
2140 KB |
Output is correct |
5 |
Correct |
63 ms |
7168 KB |
Output is correct |
6 |
Correct |
38 ms |
5828 KB |
Output is correct |
7 |
Correct |
59 ms |
6980 KB |
Output is correct |
8 |
Correct |
59 ms |
7128 KB |
Output is correct |
9 |
Correct |
0 ms |
212 KB |
Output is correct |
10 |
Correct |
1 ms |
212 KB |
Output is correct |
11 |
Correct |
0 ms |
212 KB |
Output is correct |
12 |
Correct |
1924 ms |
300 KB |
Output is correct |
13 |
Correct |
0 ms |
212 KB |
Output is correct |
14 |
Execution timed out |
2072 ms |
212 KB |
Time limit exceeded |
15 |
Halted |
0 ms |
0 KB |
- |