QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#686236 | #8723. 乘二 | Xwc | WA | 1ms | 5640kb | C++14 | 1.9kb | 2024-10-29 09:23:23 | 2024-10-29 09:23:25 |
Judging History
answer
#include <bits/stdc++.h>
#define fastio ios::sync_with_stdio(false), cin.tie(0), cout.tie(0)
typedef double ff;
typedef long long int ll;
typedef unsigned long long int ull;
typedef __int128 i128;
using namespace std;
typedef pair<ll, ll> pii;
const int N = 2e5 + 10, M = 1e7, mod = 1e9 + 7;
ll a[N], mx[N], c[N], n, k;
ll qpow(ll a, ll k)
{
ll res = 1;
while( k ) {
if(k & 1) res = res * a % mod;
k = k >> 1;
a = a * a % mod;
}
return res;
}
void solve()
{
cin >> n >> k;
for(int i = 1; i <= n; i ++ ) cin >> a[i];
sort(a + 1, a + 1 + n);
mx[n] = a[n], c[n] = 0;
for(int i = n - 1; i >= 1; i -- ) {
ll x = a[i], cnt = 0;
if(a[i] == a[i + 1]) {
mx[i] = mx[i + 1];
c[i] = c[i + 1];
} else {
while(x * 2 <= mx[i + 1]) {
x *= 2;
cnt ++;
}
mx[i] = x;
c[i] = cnt;
}
}
// for(int i = 1; i <= n; i ++ ) {
// cout << a[i] << ' ' << mx[i] << ' ' << c[i] << '\n';
// }
priority_queue<pii, vector<pii>, greater<pii> > q;
for(int i = 1; i <= n; i ++ ) {
q.push({a[i], i});
}
while(k && q.size()) {
auto t = q.top();
q.pop();
if(c[t.second] == 0) continue;
a[t.second] *= 2;
c[t.second] -= 1;
k --;
q.push({a[t.second], t.second});
}
ll sum = 0;
for(int i = 1; i <= n; i ++ ) {
// cout << a[i] << ' ';
sum = (sum + a[i]) % mod;
}
if( k ) {
ll r = k / n, ex = k % n;
sum = sum * qpow(2, r) % mod;
for(int i = 1; i <= ex; i ++ ) {
ll tmp = a[i] * qpow(2, r) % mod;
sum = ((sum - tmp) % mod + mod) % mod;
tmp = tmp * 2 % mod;
sum = (sum + tmp) % mod;
}
}
// cout << sum % mod << '\n';
cout << 100 * qpow(2, 100) % mod;
// for(int i = 1; i <= n; i ++ ) {
// cout << a[i] << ' ';
// }
}
int main()
{
// fastio;
int t = 1;
// cin >> t;
while( t -- ) solve();
}
詳細信息
Test #1:
score: 0
Wrong Answer
time: 1ms
memory: 5640kb
input:
3 3 7 2 1
output:
637127821
result:
wrong answer 1st numbers differ - expected: '15', found: '637127821'