QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#418508 | #8723. 乘二 | lulujia5454# | RE | 0ms | 3724kb | C++20 | 1.1kb | 2024-05-23 14:17:26 | 2024-05-23 14:17:28 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
#define int long long
const int N = 2e5 + 50;
const int mod1 = 1e9 + 7;
typedef long long ll;
int a[N*2];
int ans = 0;
set<int> s;
vector<int> v;
int qsm(int x, int k)
{
int ans = 1;
while (k)
{
if (k & 1)
ans *= x;
x *= x;
k /= 2;
x %= mod1;
ans %= mod1;
}
return ans;
}
void solve()
{
int n, k;
cin >> n >> k;
for (int i = 1; i <= n; i++)
cin >> a[i], s.emplace(a[i]);
while (*s.begin() < 1e9)
{
int x = *s.begin();
s.insert(x * 2);
s.erase(x);
k--;
if (k == 0)
break;
}
for (auto ff : s)
v.push_back(ff);
for (int i = 0; i < n; i++)
{
v[i] = v[i] % mod1 * qsm(2, k / n + (i < k % n)) % mod1;
}
for (auto ff : v)
{
ans += ff;
ans %= mod1;
}
cout << ans << endl;
}
signed main()
{
ios::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
int t = 1;
// cin >> t;
while (t--)
solve();
return 0;
}
詳細信息
Test #1:
score: 100
Accepted
time: 0ms
memory: 3724kb
input:
3 3 7 2 1
output:
15
result:
ok 1 number(s): "15"
Test #2:
score: -100
Runtime Error
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...