QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#602553 | #8723. 乘二 | Kanate# | WA | 42ms | 6704kb | C++14 | 1.3kb | 2024-10-01 10:40:08 | 2024-10-01 10:40:14 |
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) 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) % mod ;
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) % mod ;
t[j].c++;
k -- ;
}
}
}
ll w = k / n; k = k % n;
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;
}
详细
Test #1:
score: 100
Accepted
time: 0ms
memory: 3700kb
input:
3 3 7 2 1
output:
15
result:
ok 1 number(s): "15"
Test #2:
score: -100
Wrong Answer
time: 42ms
memory: 6704kb
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'