社区讨论
求调,出现了re
P8160[JOI 2022 Final] 星际蛋糕 / Intercastellar参与者 1已保存回复 0
讨论操作
快速查看讨论及其快照的属性,并进行相关操作。
- 当前回复
- 0 条
- 当前快照
- 1 份
- 快照标识符
- @lylal798
- 此快照首次捕获于
- 2024/07/14 16:27 2 年前
- 此快照最后确认于
- 2024/07/14 17:48 2 年前
感觉我的思路比较简单,但是有re的点,蒟蒻求助大佬帮帮忙。
CPP#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=1e8+10;
ll res[N];
void solve()
{
ll n;
cin>>n;
vector<ll>a;
for(ll i=1,j=1;i<=n;i++,j++)
{
ll num,s=1;cin>>num;
if(num%2==0)
{
while(num%2==0)s*=2,num/=2;
j+=s-1;
}
res[j]=num;
a.push_back(j);
}
ll q;cin>>q;
while(q--)
{
ll x;cin>>x;
ll l=-1,r=a.size();
while(l+1<r)
{
ll mid=l+r>>1;
if(x<=a[mid])r=mid;
else l=mid;
}
cout<<res[a[r]]<<endl;
}
}
int main()
{
ios::sync_with_stdio(false);cin.tie(0),cout.tie(0);
solve();return 0;
}
回复
共 0 条回复,欢迎继续交流。
正在加载回复...