description:
solution:
其中序列B d|i的含义代指d能整除i 或者说 i为d的因子 那些数
需要枚举因子的话 循环节里每次加上i就好
一次性的把包含这个因子数对应的序列B值全部加上 这样就可以通过该题
code:
#include <bits/stdc++.h> using namespace std; #define LL long long #define ULL unsigned long long #define mes(x, a) memset(x, a, sizeof(x)); #define sca(a) scanf("%d", &a) #define lowbit(x) x&(-x) #define mk make_pair #define pb(x) push_back(x) #define all(x) (x).begin(), (x).end() #define fi first #define se second #define lson v << 1 #define rson v << 1 | 1 #define pii pair<int, int> inline void read(int &x) { x=0; int flag_read=1; char c=getchar(); while(c<'0'||c>'9') { if(c=='-') flag_read=-1; c=getchar(); } while(c>='0'&&c<='9') { x=(x<<3)+(x<<1)+c-'0'; c=getchar(); } x *= flag_read; } void out(int x){ if(x > 9){ out(x / 10); } putchar(x % 10 + '0'); } const int N = 2e6 + 50; LL a[N],b[N]; int main(){ int n,m; ios::sync_with_stdio(0); cin >> n >> a[1] >> m; for(int i = 2;i <= n;i ++){ a[i] = (a[i - 1] + 7 * i)%m; } for(int i = 1;i <= n;i ++){ for(int j = i;j <= n;j += i){ b[j] += a[i]; } } LL res = 0; for(int i = 1;i <= n;i ++){ res ^= b[i]; } cout << res << '\n'; return 0; }