QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#416449 | #8723. 乘二 | yangyuchen17 | WA | 48ms | 6696kb | C++14 | 1.2kb | 2024-05-21 20:49:17 | 2024-05-21 20:49:19 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
const int N=2e5+5,mod=1e9+7;
LL n,a[N],k,ans[N];
LL qp(LL a,LL b){
LL res=1,i=a;
while(b){
if(b&1) res=(res*i)%mod;
i=(i*i)%mod;
b>>=1;
}
return res%mod;
}
int main(){
cin>>n>>k;
for(int i=1;i<=n;i++){
cin>>a[i];
}
sort(a+1,a+1+n);
for(int i=2;i<=n;i++){
int l=0,r=33;
while(l<r){
int mid=l+r>>1;
if(a[i-1]*(1ll<<mid)<a[i]) l=mid+1;
else r=mid;
}
if(k>(i-1)*l){
k-=(i-1)*l;
ans[i-1]=l;
}else{
ans[i-1]=k/(i-1);
k%=(i-1);
while(k){
a[i-1]=(a[i-1]<<1)%mod;
i--;
k--;
}
break;
}
}
if(k){
ans[n]+=k/n;
k%=n;
LL x=n;
while(k){
a[x]=(a[x]<<1)%mod;
x--;
k--;
}
}
for(int i=n-1;i>=1;i--){
ans[i]+=ans[i+1];
}
for(int i=1;i<=n;i++){
//cout<<ans[i]<<" ";
ans[0]=(ans[0]+(a[i]*qp(1ll*2,ans[i]))%mod)%mod;
}
cout<<ans[0];
return 0;
}
詳細信息
Test #1:
score: 100
Accepted
time: 1ms
memory: 5556kb
input:
3 3 7 2 1
output:
15
result:
ok 1 number(s): "15"
Test #2:
score: -100
Wrong Answer
time: 48ms
memory: 6696kb
input:
200000 1605067 366760624 67854 93901 693975 27016 1046 10808 6533158 54778 500941023 77236442 32173 10431454 2 9726 1553148 89282 411182309 494073 131299543 249904771 7906930 353 9909 3632698 29156 1917186 303 737 1189004 22 1983 263 711 4106258 2070 36704 12524642 5192 123 2061 22887 66 380 1 10153...
output:
551925158
result:
wrong answer 1st numbers differ - expected: '707034173', found: '551925158'