QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#416419#8723. 乘二yangyuchen17RE 0ms0kbC++141.2kb2024-05-21 20:24:032024-05-21 20:24:03

Judging History

你现在查看的是最新测评结果

  • [2024-05-21 20:24:03]
  • 评测
  • 测评结果:RE
  • 用时:0ms
  • 内存:0kb
  • [2024-05-21 20:24:03]
  • 提交

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*l){
            k-=i*l;
            ans[i-1]=l;
        }else{
            ans[i-1]=k/i;
            k%=i;
            while(k--){
                a[i]<<=1;
                i--;
            }
            break;
        }
    }
    if(k){
        ans[n]+=k/n;
        k%=n;
        LL x=n;
        while(k--){
            a[x]=(a[x]<<1)%mod;
            x--;
        }
    }
    for(int i=n-1;i>=1;i--){
        ans[i]+=ans[i+1];
    }
    for(int i=1;i<=n;i++){
        ans[0]=(ans[0]+(a[i]*qp(1ll*2,ans[i]))%mod)%mod;
    }
    cout<<ans[0];
    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 0
Runtime Error

input:

3 3
7 2 1

output:


result: