QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#418518 | #8723. 乘二 | mingqian_233# | WA | 25ms | 7888kb | C++14 | 1.2kb | 2024-05-23 14:19:43 | 2024-05-23 14:19:44 |
Judging History
answer
#include <bits/stdc++.h>
#define int long long
#define pii pair<int, int>
using namespace std;
const int mod = 1e9 + 7;
int f_pow(int x, int y) {
if (y == 1) return x;
if (y == 0) return 1;
int t = f_pow(x, y / 2) % mod;
if (y % 2)
return t * t % mod * x % mod;
else
return t * t % mod;
}
signed main() {
ios::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
int n, k, m = 0, tot = 0;
cin >> n >> k;
vector<pii> a(n);
for (int i = 0; i < n; i++) {
cin >> a[i].first;
a[i].second = log2(a[i].first);
if (a[i].second <= (k + n - 1) / n) tot += a[i].second, m++;
}
vector<int> mult(n); // 储存这里即将乘2的多少次方
int ava = (tot + k) / m;
sort(a.begin(), a.end());
for (int i = 0; i < n; i++) {
if (a[i].second > ava) break;
mult[i] = ava - a[i].second;
k -= a[i].second;
}
int ans = 0;
for (int i = 0; i < n; i++) {
a[i].first = a[i].first * f_pow(2, mult[i]) % mod;
if (k) a[i].first = a[i].first * 2 % mod,k--;
// cout<< a[i].first << ' ';
ans = (ans + a[i].first) % mod;
}
cout << ans;
return 0;
}
詳細信息
Test #1:
score: 100
Accepted
time: 1ms
memory: 3928kb
input:
3 3 7 2 1
output:
15
result:
ok 1 number(s): "15"
Test #2:
score: -100
Wrong Answer
time: 25ms
memory: 7888kb
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:
647794892
result:
wrong answer 1st numbers differ - expected: '707034173', found: '647794892'