QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#418491#8716. 树lulujia5454#WA 0ms3636kbC++201.1kb2024-05-23 14:13:532024-05-23 14:13:53

Judging History

你现在查看的是最新测评结果

  • [2024-05-23 14:13:53]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3636kb
  • [2024-05-23 14:13:53]
  • 提交

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];
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 && k--)
    {
        int x = *s.begin();
        s.emplace(x * 2);
        s.erase(x);
    }
    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;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 0
Wrong Answer
time: 0ms
memory: 3636kb

input:

5 5 3
2 1
3 2
1 4
5 1
1 5 4 2 3
1 3
5 3
3 3

output:

20

result:

wrong answer 1st numbers differ - expected: '4', found: '20'