QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#457444#8723. 乘二ZipperCompile Error//C++141.4kb2024-06-29 12:23:152024-06-29 12:23:16

Judging History

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

  • [2024-06-29 12:23:16]
  • 评测
  • [2024-06-29 12:23:15]
  • 提交

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, arr[N], dLog[N];
long double Logarr[N];


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]);
	}

	//dLog[i]表示把前i个数的log2值都变成
	//log2(arr[i])所需要的操作次数
	for (int i = 1; i <= n; i++)
	{
		for (int j = 1; j < i; j++)
		{
			dLog[i] += floor(Logarr[i] - Logarr[j]);
		}
	}

	int stop = n, times = 0;
	for (int i = 1; i <= n; i++)
	{
		if (k < dLog[i])
		{
			stop = i - 1; break;
		}
	}
	times = k - dLog[stop];

	//先把前stop - 1个数都不断乘而直至它们的log2值都等于log2(arr[stop])
	//再把剩下的操作次数(times)***队前优先平均***分给前stop个数
	//由于可以使用快速幂,所以会比小根堆的实现更快
	for (int i = 1; i < stop; i++)
	{
		arr[i] = power(arr[i], floor(Logarr[stop] - Logarr[i]));
	}
	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;
}

詳細信息

answer.code: In function ‘int main()’:
answer.code:51:26: error: ‘power’ was not declared in this scope
   51 |                 arr[i] = power(arr[i], floor(Logarr[stop] - Logarr[i]));
      |                          ^~~~~
answer.code:56:38: error: ‘power’ was not declared in this scope
   56 |                 if (i <= s) arr[i] = power(arr[i], t + 1);
      |                                      ^~~~~
answer.code:57:31: error: ‘power’ was not declared in this scope
   57 |                 else arr[i] = power(arr[i], t);
      |                               ^~~~~