QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#457737#8723. 乘二ZipperWA 62ms8392kbC++141.3kb2024-06-29 13:50:052024-06-29 13:50:05

Judging History

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

  • [2024-06-29 13:50:05]
  • 评测
  • 测评结果:WA
  • 用时:62ms
  • 内存:8392kb
  • [2024-06-29 13:50:05]
  • 提交

answer

#include<iostream>
#include<math.h>
#include<algorithm>
using namespace std;
#define int long long

const int N = 2e5 + 5, p = 1e9 + 7;
pair<int, int> nums[N], heap[N];
int ans, sum, arr[N]; double Logarr[N];

int power(int a, int b)
{
	int tmp = 2, ans = 1;
	while (b > 0)
	{
		if (b % 2) ans = (ans * tmp) % p;
		tmp = (tmp * tmp) % p; b /= 2;
	}
	return (a * ans) % p;
}

signed main()
{
	int n, k; cin >> n >> k;
	for (int i = 1; i <= n; i++)
	{
		cin >> arr[i];
	}
	sort(arr + 1, arr + n + 1);
	for (int i = 1; i <= n; i++)
	{
		Logarr[i] = log2(arr[i]);
	}

	int stop = n, times = 0;
	int left = 1, right = n;
	while (left <= right)
	{
		int mid = (left + right) / 2; sum = 0;
		for (int i = 1; i < mid; i++)
		{
			sum += floor(Logarr[mid] - Logarr[i]);
		}

		if (sum <= k)
		{
			left = mid + 1;
                        stop = mid;
		}
		else
		{
			right = mid - 1;
		}

	}
	times = k - sum;

	for (int i = 1; i < stop; i++)
	{
		arr[i] = power(arr[i], floor(Logarr[stop] - Logarr[i]));
	}
        sort(arr + 1, arr + stop + 1);
	int t = times / stop, s = times - t * stop;
	for (int i = 1; i <= stop; i++)
	{
		if (i <= s) arr[i] = power(arr[i], t + 1);
		else arr[i] = power(arr[i], t);
	}

	for (int i = 1; i <= n; i++)
	{
		ans += arr[i]; ans %= p;
	}
	cout << ans;

	return 0;
}

詳細信息

Test #1:

score: 100
Accepted
time: 1ms
memory: 5824kb

input:

3 3
7 2 1

output:

15

result:

ok 1 number(s): "15"

Test #2:

score: -100
Wrong Answer
time: 62ms
memory: 8392kb

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:

666263299

result:

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