比赛 2024年6月13日练习赛 评测结果 AAAAAAAAAA
题目名称 异或约数和 最终得分 100
用户昵称 ┭┮﹏┭┮ 运行时间 1.479 s
代码语言 C++ 内存使用 2.29 MiB
提交时间 2024-06-13 18:13:49
显示代码纯文本
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define F(i,a,b) for(ll i = a;i <= b;i++)
#define D(i,a,b) for(ll i = a;i >= b;i--)
#define fi first
#define se second
#define pii pair<int,int>
#define pb(x) push_back(x)
const int N = 1510,M = 2e6+10;
const ll inf = 1e17,mod = 998244353;

ll read(){
    ll x = 0,f = 1;char c = getchar();
    for(;c < '0' || c > '9';c = getchar())if(c == '-')f = -1;
    for(;c >= '0' && c <= '9';c = getchar())x = (x<<3) + (x<<1) + c-'0';
    return x * f;
}


ll n,ans;
ll f(ll x){
    if(x % 4 == 1)return 1;
    if(x % 4 == 2)return x+1;
    if(x % 4 == 3)return 0;
    if(x % 4 == 0)return x;
}
int main(){
    freopen("xoradd.in","r",stdin);
    freopen("xoradd.out","w",stdout);
    n = read();
    for(ll l = 1,r;l <= n;l = r + 1){
        r = min(n / (n / l ),n);
        if((n / l) & 1)ans ^= f(r) ^ f(l-1);
    }
    printf("%lld\n",ans);

    return cerr<<endl<<"Time:"<<clock()<<"ms"<<endl,0;

}