QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#765990 | #8980. Prime Game | nnk | Compile Error | / | / | C++20 | 1.4kb | 2024-11-20 15:52:28 | 2024-11-20 15:52:28 |
Judging History
This is the latest submission verdict.
- [2024-11-20 15:52:28]
- Judged
- Verdict: Compile Error
- Time: 0ms
- Memory: 0kb
- [2024-11-20 15:52:28]
- Submitted
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);
int ans = (m ) * 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);
}
}
for (auto& [u, v] : addon) {
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:44:29: error: ‘addon’ was not declared in this scope 44 | for (auto& [u, v] : addon) { | ^~~~~