QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#754455 | #8723. 乘二 | nameless_mist# | WA | 49ms | 19980kb | C++14 | 1.3kb | 2024-11-16 15:05:27 | 2024-11-16 15:05:28 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
#define int long long
inline int read(){
int s=0,w=1;
char ch=getchar();
while(ch<'0'||ch>'9'){if(ch=='-')w=-1;ch=getchar();}
while(ch>='0'&&ch<='9')s=s*10+ch-'0',ch=getchar();
return s*w;
}
inline void out(int x){
if(x==0){putchar('0');return;}
int len=0,k1=x,c[10005];
if(k1<0)k1=-k1,putchar('-');
while(k1)c[len++]=k1%10+'0',k1/=10;
while(len--)putchar(c[len]);
}
const int N=2e5+5,V=31,mod=1e9+7;
int h_bit(int x){
int k=0;
while(x>0)k++,x>>=1;
return k;
}
int qpow(int a,int b){
int ans=1;
while(b){
if(b&1)ans=(ans*a)%mod;
b>>=1,a=(a*a)%mod;
}
return ans;
}
vector<int>v[V];
signed main(){
int n=read(),k=read();
for(int i=1;i<=n;i++){
int x=read();
v[h_bit(x)].push_back(x);
}
for(int i=0;i<V;i++){
sort(v[i].begin(),v[i].end());
if(v[i].size()==n){
int sum=0,d=k/n,r=k%n;
for(int j=0;j<r;j++)sum+=(v[i][j]*qpow(2,d+1))%mod;
for(int j=r;j<n;j++)sum+=(v[i][j]*qpow(2,d))%mod;
cout<<sum%mod;return 0;
}
for(auto x:v[i]){
if(k==0){
int sum=0;
for(int j=0;j<V;j++){
for(auto x:v[j])sum=(sum+x)%mod;
}
cout<<sum%mod;return 0;
}
k--;v[i+1].push_back(x<<1);
}
v[i].clear();
}
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3576kb
input:
3 3 7 2 1
output:
15
result:
ok 1 number(s): "15"
Test #2:
score: -100
Wrong Answer
time: 49ms
memory: 19980kb
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:
768829516
result:
wrong answer 1st numbers differ - expected: '707034173', found: '768829516'