| # | Time | Username | Problem | Language | Result | Execution time | Memory |
|---|---|---|---|---|---|---|---|
| 1299321 | quan606303 | Intercastellar (JOI22_ho_t1) | C++20 | 55 ms | 6844 KiB |
/*
* @Author: RMQuan
* @Date: 2025-12-05 09:56:25
* @Last Modified by: RMQuan
* @Last Modified time: 2025-12-05 10:19:23
*/
/*idea :
*/
#include <bits/stdc++.h>
bool M1;
#define int long long
#define ll long long
#define INTMAX INT_MAX
#define INTMIN INT_MIN
#define LONGMAX LLONG_MAX
#define LONGMIN LLONG_MIN
#define fi first
#define se second
#define memfull(a,b) memset(a,b,sizeof(a));
#define endl '\n'
#define TASK "TEST"
#define file() if (fopen(TASK".inp","r")){freopen(TASK".inp","r",stdin); freopen(TASK".out","w",stdout);}
using namespace std;
const int MOD=1e9+7;
const int maxn=2e5+7;
int n,q,a[maxn],cnt[maxn],val[maxn];
pair<int,int> cal(int x)
{
int l=0,r=30;
int ans=0;
while (l<=r)
{
int mid=(l+r)/2;
int tam=(1LL<<mid);
if (x%tam==0)
{
ans=mid;
l=mid+1;
}
else r=mid-1;
}
return {(1LL<<ans), x/(1LL<<ans)};
}
int32_t main()
{
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
file();
cin>>n;
for (int i=1;i<=n;i++) cin>>a[i];
for (int i=1;i<=n;i++)
{
pair<int,int> tmp=cal(a[i]);
cnt[i]=tmp.fi;
val[i]=tmp.se;
// cerr<<cnt[i]<<" "<<val[i]<<endl;
cnt[i]=cnt[i-1]+cnt[i];
}
cin>>q;
while (q--)
{
int x;
cin>>x;
auto it=lower_bound(cnt+1,cnt+n+1,x)-cnt;
cout<<val[it]<<endl;
}
return 0;
}
Compilation message (stderr)
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
