QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#419939#8723. 乘二QuannWA 160ms6468kbC++201.1kb2024-05-24 12:52:062024-05-24 12:52:07

Judging History

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

  • [2024-05-24 12:52:07]
  • 评测
  • 测评结果:WA
  • 用时:160ms
  • 内存:6468kb
  • [2024-05-24 12:52:06]
  • 提交

answer

#include <bits/stdc++.h>
#define debug(x) cout << #x << ' ' << x << '\n'
#define endl '\n'

using namespace std;

typedef pair<int, int> PII;
typedef long long ll;
const int N = 200010, mod = 1e9 + 7, inf = 0x3f3f3f3f;

int n, k;
ll a[N];

ll ksm(ll a, ll b) {
	a %= mod;
	b %= mod;
	ll res = 1;
	while(b) {
		if (b & 1) res = (res * a) % mod;
		b >>= 1;
		a = a * a % mod;
	}
	return res % mod;
}

void solve()
{
	cin >> n >> k;

	auto cmp = [](ll &a, ll &b) {
		return a > b;
	};

	priority_queue<ll, vector<ll>, decltype(cmp)> q(cmp);

	for (int i = 1; i <= n; i ++) {
		cin >> a[i];
		q.push(a[i]);
	}
	
	ll t = q.top();
	while(k && t < mod) {
		q.pop();
		q.push(t * 2);
		t = q.top();
		k --;
	}

	n = 0;
	while(q.size()) {
		a[++n] = q.top();
		q.pop();
	}
	
	ll p = k / n;
	ll ans = 0;
	int sum = k % n;
	for (int i = 1; i <= n; i ++) {
		if (sum) {
			ans += 2 * a[i] * ksm(2, p) % mod;
			sum --;
		} else {
			ans += a[i] * ksm(2, p) % mod;
		}
	}
	
	cout << ans << endl;

}

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0), cout.tie(0);

	solve();

	return 0;
}

详细

Test #1:

score: 100
Accepted
time: 0ms
memory: 3532kb

input:

3 3
7 2 1

output:

15

result:

ok 1 number(s): "15"

Test #2:

score: -100
Wrong Answer
time: 160ms
memory: 6468kb

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:

10953707110844

result:

wrong answer 1st numbers differ - expected: '707034173', found: '10953707110844'