代码如下
#include <iostream>
#include <ctime>
using namespace std;
#define LL unsigned long long
#define int unsigned int
const int MOD = 998244353;
static int n, k, i; LL ans;
inline int ksm(register LL a, register int p){
register int temp = 1;
for (; p; p >>= 1){
if (p & 1) temp = (1ll * temp * a) % MOD;
a *= a;a %= MOD;
}
return temp;
}
signed main(){
ios::sync_with_stdio(false);
cin >> n >> k;
for (i = 1; i <= n; ++i){
ans = ans xor (1ll * ksm((LL)(i), i) + k) % MOD;
}
cout << ans;
}
数据规模 n\le 2e7,极限情况下跑了1.2秒,请问还能怎么优化