QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#415716 | #8723. 乘二 | ANIG# | TL | 1ms | 5740kb | C++14 | 814b | 2024-05-21 09:06:32 | 2024-05-21 09:06:32 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
#define int long long
const int N=2e5+5,mods=1e9+7;
int p[N],n,k;
double g[N];
struct node{
int bh;double sm;
friend bool operator<(node a,node b){
return a.sm>b.sm;
}
};
priority_queue<node>q;
int pows(int a,int b){
if(b==0)return 1;
int res=pows(a,b>>1);
res=res*res%mods;
if(b&1)res=res*a%mods;
return res;
}
signed main(){
cin>>n>>k;
int res=0;
for(int i=1;i<=n;i++)cin>>p[i],g[i]=log2(p[i]),q.push({i,g[i]}),res+=p[i];
int cnt=0;
while(k--){
cnt++;
if(cnt>1000000){
int t=k/n;
k-=t*n;
for(int i=1;i<=n;i++)res+=(pows(2,t)-1)*p[i],res%=mods,p[i]=p[i]*pows(2,t)%mods;
}
int x=q.top().bh;
q.pop();
g[x]+=1;
q.push({x,g[x]});
res+=p[x];
p[x]=p[x]*2%mods;
res%=mods;
}
cout<<res;
}
详细
Test #1:
score: 100
Accepted
time: 1ms
memory: 5740kb
input:
3 3 7 2 1
output:
15
result:
ok 1 number(s): "15"
Test #2:
score: -100
Time Limit Exceeded
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...