1 条题解
-
0
#include<bits/stdc++.h> using namespace std; int n, k, phi[1000005]; int main() { cin >> n >> k; iota(phi, phi + n + 1, 0); long long ans = k > 1? 2: 1; for (int i = 2; i <= n; i++) if (phi[i] == i) for (int j = i; j <= n; j += i) phi[j] -= phi[j] / i; sort(phi + 3, phi + n + 1); for (int i = 0; i < k; i++) ans += phi[i + 3]; cout << ans; }
- 1
信息
- ID
- 6864
- 时间
- 1000ms
- 内存
- 256MiB
- 难度
- 10
- 标签
- 递交数
- 1
- 已通过
- 1
- 上传者