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

之后就是模拟,牛逼的思路

#include<iostream>
#include<map>
#include<iostream>
#include<cstring>
#include<cstdio>
#include<set>
#include<vector>
#include<queue>
#include<stack>
#include<algorithm>
using namespace std;
typedef long long ll;
const int N = 1e5+5;
#define MS(x,y) memset(x,y,sizeof(x))
#define MP(x, y) make_pair(x, y)
const int INF = 0x3f3f3f3f; int prime[N];
int isprime[N]; int tot = 0;
int n;
map<int, int> mp;
map<int, int> dp;
map<int, int> ::iterator it; int solve(int x){
if(dp.find(x) != dp.end()) return dp[x];
int mex[35];
MS(mex, 0);
for(int i = 0; x >> i; ++i) {
int tt = solve( (x >> (i + 1)) | ( ((1<<i) - 1) & x ) );
mex[tt] ++;
} for(int i = 0; i < 35; ++i) {
if(!mex[i]) {
dp[x] = i;
return i;
}
}
}
int main() {
for(int i = 2; i < N; ++i) {
if(isprime[i] == 0) {
prime[++tot] = i;
for(int j = 2*i; j < N; j += i) {
isprime[j] ++;
}
}
}
while(~scanf("%d", &n)) {
mp.clear(); for(int i = 0; i < n; ++i) {
int a; scanf("%d", &a);
for(int j = 1; j <= tot; ++j) {
if(a % prime[j] == 0) {
int cnt = 0;
while(a % prime[j] == 0) a /= prime[j], cnt ++;
mp[prime[j]] |= 1<<(cnt-1);
if(a == 1) break;
}
}
if(a != 1) {
mp[a] |= 1;
}
} int ans = 0;
for(it = mp.begin(); it != mp.end(); ++it) {
dp.clear();
ans ^= solve(it -> second);
}
if(ans) printf("Mojtaba\n");
else printf("Arpa\n");
}
return 0;
}

Codeforces Round #432 Div. 1 C. Arpa and a game with Mojtaba的更多相关文章

  1. Codeforces Codeforces Round #432 (Div. 2 D ) Arpa and a list of numbers

    D. Arpa and a list of numbers time limit per test   2 seconds memory limit per test     256 megabyte ...

  2. Codeforces Round #432 (Div. 1) B. Arpa and a list of numbers

    qtmd的复习pat,老子不想看了,还不如练几道cf 这题首先可以很容易想到讨论最后的共因子为素数 这个素数太多了,1-1e6之间的素数 复杂度爆炸 所以使用了前缀和,对于每个素数k的每个小区间 (k ...

  3. D. Arpa and a list of numbers Codeforces Round #432 (Div. 2, based on IndiaHacks Final Round 2017)

    http://codeforces.com/contest/851/problem/D 分区间操作 #include <cstdio> #include <cstdlib> # ...

  4. 【前缀和】【枚举倍数】 Codeforces Round #432 (Div. 2, based on IndiaHacks Final Round 2017) D. Arpa and a list of numbers

    题意:给你n个数,一次操作可以选一个数delete,代价为x:或者选一个数+1,代价y.你可以进行这两种操作任意次,让你在最小的代价下,使得所有数的GCD不为1(如果全删光也视作合法). 我们从1到m ...

  5. 【推导】Codeforces Round #432 (Div. 2, based on IndiaHacks Final Round 2017) B. Arpa and an exam about geometry

    题意:给你平面上3个不同的点A,B,C,问你能否通过找到一个旋转中心,使得平面绕该点旋转任意角度后,A到原先B的位置,B到原先C的位置. 只要A,B,C构成等腰三角形,且B为上顶点.那么其外接圆圆心即 ...

  6. 【Codeforces Round #432 (Div. 2) A】 Arpa and a research in Mexican wave

    [链接]h在这里写链接 [题意] 在这里写题意 [题解] t<=k,输出t t>=n,输出k-t+n 其他情况都是k [错的次数] 0 [反思] 在这了写反思 [代码] /* */ #in ...

  7. 【Codeforces Round #432 (Div. 2) B】Arpa and an exam about geometry

    [链接]h在这里写链接 [题意] 给你3个点A,B,C 问你能不能将纸绕着坐标轴上的一点旋转.使得A与B重合,B与C重合 [题解] 这3个点必须共圆. 则A,B,C不能为一条直线.否则无解. 共圆之后 ...

  8. 【Codeforces Round #432 (Div. 1) B】Arpa and a list of numbers

    [链接]h在这里写链接 [题意] 定义bad list是一个非空的.最大公约数为1的序列.给定一个序列,有两种操作:花费x将一个元素删除.花费y将一个元素加1,问你将这个序列变为good list所需 ...

  9. Codeforces Round #383 (Div. 2) C. Arpa's loud Owf and Mehrdad's evil plan —— DFS找环

    题目链接:http://codeforces.com/contest/742/problem/C C. Arpa's loud Owf and Mehrdad's evil plan time lim ...

随机推荐

  1. 让44.1版本的sketch打开更高版本的sketch文件

    我们都知道,sketch的有效license与版本挂钩.最近设计师又更新了sketch版本,导致她生成的源文件我都无法打开. 毕竟我不是使用sketch进行UI设计,仅用它来查看设计稿参数,再花99美 ...

  2. es随想二

    一.es运行状态的监控 es长时间批量入库时,需要对入库的性能进行监控,否则可能导致es重启,入库任务失败. 可以编写shell脚本,每分钟用cat命令监控pending的数量,数量逐渐增大时就需要注 ...

  3. [偏序关系与CDQ分治]【学习笔记】

    组合数学真是太棒了 $CDQ$真是太棒了(雾 参考资料: 1.<组合数学> 2.论文 课件 很容易查到 3.sro __stdcall 偏序关系 关系: 集合$X$上的关系是$X$与$X$ ...

  4. Centos7搭建FTP服务器

    从网上搜索了好多搭建Centos7搭建服务器的教程都没有成功唯独这个,利用Windows资源管理器连接测试成功. 一.通过yum安装vsftpd yum install -y vsftpd 二.修改v ...

  5. 【翻译】CSS Animations VS the Web Animations API:案例学习

    原文地址:CSS Animations vs the Web Animations API: A Case Study May 03, 2017 css, javascript 上周我写了我如何使用C ...

  6. iOS开发中UIPopoverController的使用详解

    这篇文章主要介绍了iOS开发中UIPopoverController的使用,代码基于传统的Objective-C,需要的朋友可以参考下 一.简单介绍 1.什么是UIPopoverController ...

  7. 加快compser install 和update的方法

    加快compser install 和update的方法: 可以进入composer国内镜像里面进行参考 如下是修改composer.json文件来实现(在json配置的最后加上如下代码) " ...

  8. 【linux之find及awk】

    一.find命令 find 精确查找,根据提供的条件或组合条件进行查找,遍历所有文件,因此速度比较慢. 语法: find 目录 条件 动作 默认目录是当前目录默认条件是所有条件默认动作是显示查找到的信 ...

  9. JavaScript 历史漫谈

    话说 JavaScript 其实是诞生在一个特殊的时期,20世纪90年代,正值第三次科技革命时期,互联网刚开始进入人们的生活.设想一下,在网速只有几十比特的那个时代,在登录注册时要花上很长一段时间等待 ...

  10. ADO.NET通用类库

    using System.Data; using System.Data.SqlClient; namespace DataService { public class SQLHelper { pub ...