QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#417135 | #8723. 乘二 | char_miii | TL | 0ms | 1880kb | C11 | 1.1kb | 2024-05-22 14:56:51 | 2024-05-22 14:56:52 |
Judging History
answer
#include<stdio.h>
#include<math.h>
#include<stdlib.h>
#define MOD 1000000007
#define MAX 536870912
long long a[200000];
int m[200000];
int cmp_t(const void* p1,const void* p2){
return (*(int*)p1-*(int*)p2);
}
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,summ=0;
long long k,min=0,sum=0;
scanf("%d%lld",&n,&k);
getchar();
for(int i=0;i<n;i++){
scanf("%lld",&a[i]);
m[i]=30-(int)log2(a[i]);
summ+=m[i];
if(a[i]<a[min]) min=i;
}
if(summ<=k){
for(int i=0;i<n;i++){
a[i]=qp(2,m[i])*a[i];
sum=(sum+a[i])%MOD;
}
if(summ<k){
for(long long j=0;j+n<k-summ;j+=n){
sum=(sum*2)%MOD;
}
int sz=sizeof(a)/sizeof(a[0]);
qsort(a,sz,sizeof(a[0]),cmp_t);
for(int i=0;i<(k-summ)%n;i++){
sum+=a[i];
}
}
}
else{
for(long long 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: 1880kb
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...