QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#602565 | #8723. 乘二 | Kanate# | WA | 33ms | 6680kb | C++14 | 1.5kb | 2024-10-01 10:47:29 | 2024-10-01 10:47:30 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 2e5 + 7;
const int mod = 1e9 + 7;
ll ans ;
int n , k ;
struct node {
ll a , c;
}t[N];
ll qpow(ll a,ll b){
ll ans = 1;
for(;b;b>>=1,a=a*a%mod) if(b&1)ans = ans * a %mod;
return ans;
}
bool cmp(node a,node b){
if(a.c !=b.c)return a.c < b.c;
return a.a< b.a;
}
int main(){
ios::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
cin >> n >> k;
for(int i=1;i<=n;i++) {
cin >> t[i].a;ll w = t[i].a;
ans += w;
ans %= mod;
while(w){
t[i].c++;
w/=2;
}
t[i].c -- ;
// cout << i << " " << t[i].c << endl;
}
sort(t+1,t+n+1,cmp);
ll sum = 0 ;
for(int i=1;i<=n;i++){
while(t[i].c < t[i+1].c){
if(k <= i){
for(int j=1;j<=k;j++){
// cout << j << " " << t[j].a << endl;
ans = (ans + t[j].a) %mod;
t[j].a = (t[j].a + t[j].a);
t[j].c++;
}
cout << ans ;
return 0;
}
else
for(int j=1;j<=i;j++){
// cout << t[j].a << endl;
ans = (ans + t[j].a) %mod;
t[j].a = (t[j].a + t[j].a) ;
t[j].c++;
k -- ;
}
}
}
// cout << k << " " << ans << endl;
sort(t+1,t+n+1,cmp);
for(int i=1;i<=n;i++) t[i].a %= mod ;
ll w = k / n; k = k % n;
// cout << qpow(2,w) << endl;
ans = ans * qpow(2,w) % mod;
ll pw = qpow(2,w);
for(int j=1;j<=k;j++){
t[j].a = t[j].a * pw %mod;
ans = (ans + t[j].a ) %mod;
}
cout << ans;
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3556kb
input:
3 3 7 2 1
output:
15
result:
ok 1 number(s): "15"
Test #2:
score: -100
Wrong Answer
time: 33ms
memory: 6680kb
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:
609616159
result:
wrong answer 1st numbers differ - expected: '707034173', found: '609616159'