Dihedral Group
猜结论,我们观察样例就可以猜到,只要 \(t\) 可以被 \(d\) 在一个圆上正着或泛着表示即可
#include <bits/stdc++.h>
using namespace std;
#define int long long
const int N = 5e4 + 5;
int n, m, a[N], b[N], pos[N];
signed main() {
cin >> n >> m;
for (int i = 0; i < n; i++) {
cin >> a[i];
pos[a[i]] = i;
}
for (int i = 1; i <= m; i++) {
cin >> b[i];
}
for (int i = 2; i <= m; i++) {
int tmp = (pos[b[i]] + n - pos[b[i - 1]]) % n;
int tmp1 = (pos[b[i - 1]] + n - pos[b[i]]) % n;
if (min(tmp, tmp1) != 1) {
cout << 0;
return 0;
}
}
cout << 1;
return 0;
}//
Passport Stamps
也是结论题,非常好想,没什么好说的
#include <bits/stdc++.h>
using namespace std;
#define int long long
int n, p, c;
signed main() {
cin >> n >> p;
__int128 sum = 0;
for (__int128 i = 1; i <= n; i++) {
cin >> c;
if ((i - 1) * (c - 1) + c + sum > p) {
int tmp = i - 1;
cout << tmp;
return 0;
}
sum += c;
}
cout << n;
return 0;
}//
标签:__,20240909,int,sum,cin,long,pos
From: https://www.cnblogs.com/libohan/p/18473012