Problem - 1514C - Codeforces
题意:
思路:
Code:
#include <bits/stdc++.h>
using i64 = long long;
constexpr int N = 2e5 + 10;
constexpr int M = 2e5 + 10;
constexpr int mod = 998244353;
void solve() {
int n;
std::cin >> n;
std::vector<int> ans;
i64 mul = 1ll;
for (int i = 1; i <= n - 1; i ++) {
if (std::__gcd(i, n) == 1) {
ans.push_back(i);
mul *= i;
mul %= n;
}
}
if (mul == 1ll) {
std::cout << ans.size() << "\n";
for (int i = 0; i < ans.size(); i ++) {
std::cout << ans[i] << " \n" [i == ans.size() - 1];
}
}else {
std::cout << ans.size() - 1 << "\n";
for (int i = 0; i < ans.size() - 1; i ++) {
if (ans[i] != n) {
std::cout << ans[i] << " ";
}
}
std::cout << "\n";
}
}
signed main() {
std::ios::sync_with_stdio(false);
std::cin.tie(nullptr);
int t = 1;
while(t --) {
solve();
}
return 0;
}