QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#417063 | #8723. 乘二 | char_miii | TL | 0ms | 4204kb | C99 | 890b | 2024-05-22 13:55:39 | 2024-05-22 13:55:40 |
Judging History
answer
#include<stdio.h>
#include<math.h>
#define MOD 1000000007
#define MAX 536870912
long long a[200000];
int m[200000];
long long qp(long long a,long long b){
long long z=1;
while(b){
if(b&1) z=z*a%MOD;
a=a*a%MOD;
b>>=1;
}
return z;
}
int main(){
int n,flag=0;
long long k,min=0,sum=0,summ=0;
scanf("%d%lld",&n,&k);
getchar();
for(int i=0;i<n;i++){
scanf("%lld",&a[i]);
m[i]=(int)((29-log(a[i]))/log(2))+1;
summ+=m[i];
if(a[i]<a[min]) min=i;
}
if(summ<=k){
for(int i=0;i<n;i++){
sum=(sum+qp(2,m[i])*a[i])%MOD;
}
if(summ<k){
for(long long j=0;j<k-summ;j+=n){
sum=(sum*2)%MOD;
}
}
}
else{
long long i;
for(i=0;i<k;i++){
a[min]*=2;
min=0;
for(int j=0;j<n;j++){
if(a[j]<a[min]) min=j;
}
}
for(int t=0;t<n;t++){
sum=(sum+a[t])%MOD;
}
}
printf("%lld",sum);
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 4204kb
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...