QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#765986#8980. Prime GamennkCompile Error//C++201.4kb2024-11-20 15:51:472024-11-20 15:51:48

Judging History

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

  • [2024-11-20 15:51:48]
  • 评测
  • [2024-11-20 15:51:47]
  • 提交

answer

#include<bits/stdc++.h>
#define int long long
#define N 10005
#define MAX 1000004
using namespace std;
vector<int> a;
int cal(int n) {
	return n * (n + 1) / 2;
}
void slove()
{
	int n; cin >> n;
	vector<int> all(n);
	for (auto& x : all)cin >> x;
	int m = a.size();
	vector<vector<int>> cnt(m);
	for (int i = 0; i < m; i++)cnt[i].emplace_back(-1);
	for (int i = 0; i < n; i++) {
		int u = all[i];
		bool is = 1;
		for (int j = 0; j < m;j++) {
			int v = a[j];
			if (u % v == 0) {
				cnt[j].emplace_back(i);
				is = 0;
			}
		}

	}
	for (int i = 0; i < m; i++)cnt[i].emplace_back(n);
	for (auto& [u, v] : addon)v.emplace_back(n);
int tmp=addon.size();
	int ans = (m + tmp) * n * (n + 1) / 2;
	
	for (int i = 0; i < m; i++) {
		auto& v = cnt[i];
		int len = v.size();
		for (int j = 1; j < len;j++) {
			int x = v[j] - v[j - 1] - 1 ;
			ans -= cal(x);
		}
	}

	cout << ans << endl;
}
signed main()
{
	for (int i = 2; i <= 1000000; i++) {
		int ok = 0;
		for (int j = 2; j <= sqrt(i); j++) {
			if (i % j == 0) { ok = 1; break; }
		}
		if (!ok) a.push_back(i);
	}
	ios::sync_with_stdio(false), cin.tie(nullptr);
	int t = 1;
//	cin >> t;
	while (t--) {
		slove();
	}
	return 0;
}
/*
3
5
0 5 -2 1 2
9 -4 0 10 5
-4 -1 4 -2 4
10
-6 3 1 0 6 -2 -4 3 0 10
22 65 11 1 -34 -1 -39 -28 25 24
10 9 1 -2 -5 8 -7 -10 -7 -7
1
101
48763
651
*/

详细

answer.code: In function ‘void slove()’:
answer.code:31:29: error: ‘addon’ was not declared in this scope
   31 |         for (auto& [u, v] : addon)v.emplace_back(n);
      |                             ^~~~~
answer.code:32:9: error: ‘addon’ was not declared in this scope
   32 | int tmp=addon.size();
      |         ^~~~~