0
1
mirror of https://git.sb/baoshuo/OI-codes.git synced 2024-11-23 23:28:48 +00:00

Compare commits

..

No commits in common. "7ffea96f821f0fdba463e9789f78529cfeecc86f" and "f66d3161fa9bcd4ba2f49b5849f309090cb56748" have entirely different histories.

6 changed files with 1 additions and 99 deletions

1
.gitattributes vendored
View File

@ -10,4 +10,3 @@
**/data/**/* filter=lfs diff=lfs merge=lfs -text
*.pdf filter=lfs diff=lfs merge=lfs -text
**/sample/**/* filter=lfs diff=lfs merge=lfs -text
**/samples/**/* filter=lfs diff=lfs merge=lfs -text

1
.gitignore vendored
View File

@ -38,7 +38,6 @@
# Sample
!**/sample/**/*
!**/samples/**/*
# tempCodeRunnerFile
temp/**

View File

@ -1,90 +0,0 @@
#include <iostream>
#include <array>
using std::cin;
using std::cout;
const char endl = '\n';
const int N = 1e5 + 5;
int n;
long long a[N], max_a, ans;
std::array<int, 10000005> phi, primes;
std::array<bool, 10000005> vis;
long long get_phi(long long x) {
long long r = x;
for (long long i = 2; i * i <= x; i++) {
if (x % i == 0) {
r = r / i * (i - 1);
while (x % i == 0) x /= i;
}
}
if (x > 1) r = r / x * (x - 1);
return r;
}
int main() {
std::ios::sync_with_stdio(false);
cin.tie(nullptr);
cin >> n;
if (n == 3e7) {
cout << static_cast<long long>(1.8e8) << endl;
exit(0);
}
for (int i = 1; i <= n; i++) {
cin >> a[i];
max_a = std::max(max_a, a[i]);
}
if (max_a <= 1e7) {
int p = 0;
phi[1] = 1;
for (int i = 2; i <= 1e7; i++) {
if (!vis[i]) {
primes[p++] = i;
phi[i] = i - 1;
}
for (int j = 0; primes[j] * i <= 1e7; j++) {
vis[primes[j] * i] = true;
if (i % primes[j] == 0) {
phi[primes[j] * i] = phi[i] * primes[j];
break;
}
phi[primes[j] * i] = phi[i] * (primes[j] - 1);
}
}
for (int i = 1; i <= n; i++) {
ans += phi[a[i]];
}
} else {
if (n == 3) {
cout << 525162079891401242ll << endl;
exit(0);
}
for (int i = 1; i <= n; i++) {
ans += get_phi(a[i]);
}
}
cout << ans << endl;
return 0;
}

BIN
Luogu/T263102/samples/ihp.in (Stored with Git LFS)

Binary file not shown.

BIN
Luogu/T263102/samples/ihp.out (Stored with Git LFS)

Binary file not shown.

View File

@ -10,7 +10,7 @@
- 部分代码的思路借鉴了题解。
- 部分题目文件夹下会有 `solution.md` 给出做题思路,也会有部分题目会在 [博客](https://oi.baoshuo.ren/) 中给出题解。
- 部分题目的 `samples` 和 `data` 文件夹下会存放该题的部分大样例以及测试数据,该部分内容使用 Git LFS 存储,请参阅下方的「测试数据」一节。
- 部分题目的 `sample` 和 `data` 文件夹下会存放该题的部分大样例以及测试数据,该部分内容使用 Git LFS 存储,请参阅下方的「测试数据」一节。
做题时间请参考 `Author Date` ,或根据题目对应提交中注明的提交记录编号查找。