Hitachi Vantara Programming Contest 2024(AtCoder Beginner Contest 368)F - Dividing Game

https://atcoder.jp/contests/abc368/tasks/abc368_f

#include<bits/stdc++.h>
#define x first
#define y second
using namespace std;
typedef long long ll;
typedef pair<ll,char> pii;
const int N=2e5+10,inf=1e9;
ll n,m,k;
int b[N],sg[N],a[N];
vector<int> divi[N];//divi[i]为小于i的所有因子
void init()
{
    for(int i=1;i<N;i++)
        for(int j=2*i;j<N;j+=i)
            divi[j].push_back(i);

    sg[1]=0;
    for(int i=2;i<N;i++)
    {
        for(auto x:divi[i])
            b[sg[x]]=1;
        while(b[sg[i]]) sg[i]++;
        for(auto x:divi[i])
            b[sg[x]]=0;
    }
}
void solve()
{
    init();
    cin>>n;
    int res=0;
    for(int i=1;i<=n;i++)
    {
        cin>>a[i];
        res^=sg[a[i]];
    }
    if(res) puts("Anna");
    else puts("Bruno");
}
int main()
{
    ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);

    int _=1;
    //cin>>_;
    while(_--)
    {
        solve();
    }

    return 0;
}
posted @   昊天djh  阅读(11)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· 地球OL攻略 —— 某应届生求职总结
· 周边上新:园子的第一款马克杯温暖上架
· Open-Sora 2.0 重磅开源!
· 提示词工程——AI应用必不可少的技术
· .NET周刊【3月第1期 2025-03-02】
点击右上角即可分享
微信分享提示