QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#602525 | #8723. 乘二 | xing4c# | WA | 27ms | 7836kb | C++14 | 1.2kb | 2024-10-01 10:15:59 | 2024-10-01 10:15:59 |
Judging History
answer
#include <bits/stdc++.h>
#define NOSYNC ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define all(x) x.begin(), x.end()
#define endl '\n'
#define int ll
using namespace std;
using ll = long long;
using ull = unsigned long long;
const int N = 200005;
const int MOD = 1e9+7;
// -------------- Templates Above -------------------------
int qpow(int a, int b) {
int res = 1;
while(b) {
if(b & 1) res = res * a % MOD;
a = a * a % MOD;
b >>= 1;
}
return res;
}
void solve() {
int n, k; cin >> n >> k;
vector<int> a(n);
vector<int> b(n); vector<int> c(n, 0);
for(int i = 0; i < n; i ++) cin >> a[i];
sort(all(a));
int mx = 0;
for(int i = 0; i < n; i ++) {
b[i] = log2(a[i]);
mx = max(mx, b[i]);
}
for(int i = 0; i < n; i ++) {
int d = mx - b[i];
if(k >= d) {
k -= d;
c[i] += d;
}
else {
c[i] += k;
k = 0;
}
}
int q = k / n; int r = k % n;
for(int i = 0; i < r; i ++) {
c[i] += q + 1;
}
for(int i = r; i < n; i ++) {
c[i] += q;
}
int ans = 0;
for(int i = 0; i < n; i ++) {
int now = qpow(2, c[i]);
now = now * a[i] % MOD;
ans = (ans + now) % MOD;
}
cout << ans << endl;
}
signed main() {
NOSYNC;
solve();
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3808kb
input:
3 3 7 2 1
output:
15
result:
ok 1 number(s): "15"
Test #2:
score: -100
Wrong Answer
time: 27ms
memory: 7836kb
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:
908756337
result:
wrong answer 1st numbers differ - expected: '707034173', found: '908756337'