标签:return 角度 codeforce 不必要 ons puts ack read pre
const int maxn = 1e5 + 5;
int n, m;
vector<pii> p;
vector<int> d;
void pre(int n) {
for (int i = 2; i <= n; i++) {
if (n % i) continue;
d.emplace_back(i);
while (n % i == 0) n /= i;
}
}
int main() {
read(n), read(m);
pre(n);
for (int i = 1, a, b; i <= m; i++) {
read(a), read(b);
a--, b--;
if (a > b) swap(a, b);
p.emplace_back(a, b);
}
sort(All(p));
for (int x : d) {
int k = n / x;
vector<pii> t;
rep(i, 0, m - 1) {
int a = p[i].first, b = p[i].second;
a = (a + k) % n, b = (b + k) % n;
if (a > b) swap(a, b);
t.emplace_back(a, b);
}
sort(All(t));
if (p == t) {
puts("Yes"); return 0;
}
}
puts("No"); return 0;
}
标签:return 角度 codeforce 不必要 ons puts ack read pre
原文地址:https://www.cnblogs.com/AlphaWA/p/10961662.html