对每个数统计其素数因子各次方数的数,然后通过y = (x>>i) | (x&((1<<(i-1))-1)) 模拟delete x and add  to the list 操作,用grund函数将每个因子的情况映射为NIM问题中一个堆的情况,再按NIM问题的求解方法求解

参考链接 https://www.topcoder.com/community/data-science/data-science-tutorials/algorithm-games/

#include<bits/stdc++.h>
using namespace std;
map<int,int> mp;
unordered_map<int,int> ttmp;
int n,tmp,y;
int grund(int x){
if(ttmp.count(x)) return ttmp[x];
unordered_set<int> s;
for(int i = ;i<=;i++){
y = (x>>i) | (x&((<<(i-))-));
if(y!=x) s.insert(grund(y));
} int ans = ;
while(s.count(ans)) ans++;
return ttmp[x] = ans;
}
int main(){
cin>>n;
for(int i = ;i<n;i++){
cin>>tmp;
for(int j = ;j*j<=tmp;j++){
if(tmp%j == ){
int cnt = ;
while(tmp%j == ){
tmp/=j;
cnt++;
}
mp[j] |= (<<cnt-);
}
}
if(tmp>) mp[tmp] |= ;
}
int ans = ;
ttmp[] = ;
for(auto t : mp){
ans^=grund(t.second);
}
cout<<(ans?"Mojtaba":"Arpa")<<endl;
return ;
}

Codeforces 850C E. Arpa and a game with Mojtaba的更多相关文章

  1. Codeforces 850C Arpa and a game with Mojtaba

    题意:给定一个正整数序列,两人轮流对这个数列进行如下修改:选取一个素数p和一个整数k将序列中能整除p^k的数除以p^k,问谁有必胜策略. 借此复习一下sg函数吧,sg(x) = mex ( sg(y) ...

  2. 【codeforces 742C】Arpa's loud Owf and Mehrdad's evil plan

    time limit per test1 second memory limit per test256 megabytes inputstandard input outputstandard ou ...

  3. 【codeforces 742B】Arpa’s obvious problem and Mehrdad’s terrible solution

    time limit per test1 second memory limit per test256 megabytes inputstandard input outputstandard ou ...

  4. 【codeforces 742A】Arpa’s hard exam and Mehrdad’s naive cheat

    time limit per test1 second memory limit per test256 megabytes inputstandard input outputstandard ou ...

  5. 【42.86%】【codeforces 742D】Arpa's weak amphitheater and Mehrdad's valuable Hoses

    time limit per test1 second memory limit per test256 megabytes inputstandard input outputstandard ou ...

  6. Codeforces 741B:Arpa's weak amphitheater and Mehrdad's valuable Hoses(01背包+并查集)

    http://codeforces.com/contest/741/problem/B 题意:有 n 个人,每个人有一个花费 w[i] 和价值 b[i],给出 m 条边,代表第 i 和 j 个人是一个 ...

  7. Codeforces 741A:Arpa's loud Owf and Mehrdad's evil plan(LCM+思维)

    http://codeforces.com/problemset/problem/741/A 题意:有N个人,第 i 个人有一个 a[i],意味着第 i 个人可以打电话给第 a[i] 个人,所以如果第 ...

  8. Codeforces Round #432 Div. 1 C. Arpa and a game with Mojtaba

    首先容易想到,每种素数是独立的,相互sg就行了 对于一种素数来说,按照的朴素的mex没法做... 所以题解的简化就是数位化 多个数同时含有的满参数因子由于在博弈中一同变化的,让他们等于相当于,那么这样 ...

  9. Codefroces 850C Arpa and a game with Mojtaba

    Description两个人Van♂游戏.给出$n$个正整数$ai$两人轮流操作,每次选出一个素数$p$和一个幂数$k$,选择的前提为该$n$个数中有$p^{k}$的倍数.接着将所有的$p^{k}$的 ...

随机推荐

  1. 学习 TTreeView [15] - 连接数据库 (作为给 "丁永其" 和 "DELPHI万岁" 两位朋友的回复)

    本例效果图: unit Unit1; interface uses   Windows, Messages, SysUtils, Variants, Classes, Graphics, Contro ...

  2. win7下Excel2003/2010 同时打开多个独立窗口

    最近新买了本本,装了许多软件,由于许多苦逼的原因系统被我搞的乱乱的,不得已重装了几次,话说之前我用的都是台式机,用得蛮顺的,但是在重装系统之后发现自己装的Office 2003 在打开Excel 文档 ...

  3. C#数字除法

    C#中计算double a=1/1000:应该结果是0.001,但为什么会变成0呢? C# 中 如果相除的两个数都是整数(int 型) 那么除的结果就是只取整数部分 所以你才会取到0 如果你要取精确的 ...

  4. SQL 创建表

    SQL 创建表是通过SQL CREATE TABLE 语句来实现,该语句是DDL SQL语句.CREATE TABLE语句用于创建用于存储数据的表.在创建表时,可以为列定义主键.惟一键和外键等完整性约 ...

  5. Android 反编译技术流程

    为何需要反编译 作为一名Android开发者,很多的时候需要去学习别人优秀的代码,原本在GitHub上就有很多开源的项目代码,但有的时候在使用软件时候遇到自己想要的功能时,想要学习实现的代码时,这时候 ...

  6. Mysql统计每年每个月的数据——详细教程

    Mysql统计每年每个月的数据(前端页面统计图实现) 最终想实现的效果图,在这里就不多废话了,直接上效果图,由于测试数据有几个月是为0的,所以数据图看着会有点怪怪. 接下来是数据库的两个表,这里直接给 ...

  7. Redis 数据类型String 使用

    字符串是Redis中最基本的数据类型,它能够存储任何类型的字符串,包含二进制数据.可以用于存储邮箱,JSON化的对象,甚至是一张图片,一个字符串允许存储的最大容量为512MB.字符串是其他四种类型的基 ...

  8. python邮件发送自动化测试报告

    话不多说直接贴代码 # encoding: utf-8import smtplib #发送邮件模块from email.mime.text import MIMEText #邮件内容from emai ...

  9. 在ROS系统下,获取tango的RGBD信息和Pose信息

    Project Tango 是从Google 的 Advanced Technology and Projects group (ATAP) 孵化出来的一个项目,诚如ATAP高级工程师Johnny L ...

  10. Jmeter plugins 之 Perfmon Metrics Collector(服务器性能监控)

    客户端(Jmeter端) 1.安装plugins manager,然后安装  2.添加listener-(第1步成功后才可看到此功能)  服务端:(要监控的服务器) 1.下载ServerAgent,并 ...