首先容易想到,每种素数是独立的,相互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. Java设计模式——策略模式

    策略模式的定义: 策略模式其实特别好理解,俗话说得好,条条大路通罗马,做的都是一件事,实现的方式却可以千万种,在这种情况下,如何使得每个人都可以根据自己的喜好来选择具体的方式,在调用时可以根据不同方式 ...

  2. BZOJ 2752: [HAOI2012]高速公路(road) [线段树 期望]

    2752: [HAOI2012]高速公路(road) Time Limit: 20 Sec  Memory Limit: 128 MBSubmit: 1219  Solved: 446[Submit] ...

  3. XML实体解析器的作用

    XML实体解析器的作用 什么是实体解析器 如果一个sax解析器需要实现对外部实体的自定义处理,那么必须实现一个EntityResolver接口并且注册到SAX驱动上. 从这段文字可以看出来,实体解析器 ...

  4. URL中特殊符号的处理

    问题描述 我们在对接第三方系统的时候通常需要get或post来传输数据,但此时如果参数中存在&% #*!包括空格等特殊符号的时候就无法正常请求具体表现在参数获取不正确或者获取不到参数,甚至有时 ...

  5. git使用基本故障

    warning: LF will be replaced by CRLF in README.md. The file will have its original line endings in y ...

  6. 发送POST测试请求的若干方法

    最近在工作中需要测试发送带Json格式body值的HTTP POST请求.起初,我在Linux环境下使用curl命令去发送请求,但是,在发送的过程中却遇到了一些问题,经过一段时间的摸索,发现了以下几种 ...

  7. Redis 实践2-数据结构

    alias redis-cli='/usr/local/redis/bin/redis-cli'   vi .bashrc 编辑加入  alias redis-cli='/usr/local/redi ...

  8. [记]WIndow/Linux 获取本机(全部)IPv4、IPv6、MAC地址方法 (C/C++)

    Linux 获取本机IP.MAC地址用法大全 //#include <sys/types.h> #include <ifaddrs.h> #include <sys/io ...

  9. Netbeans文件被误删怎么办?

    辛辛苦苦写的代码突然不见了,上午还是有的,哪去了?怎么办? 破解办法: 1,良好的版本管理工具(git||svn)使用习惯,代码每天上传更新,技术文件有丢失,也就一天的. 2,Netbeans提供的备 ...

  10. Mysql(六):数据备份、pymysql模块

    一 IDE工具介绍 生产环境还是推荐使用mysql命令行,但为了方便我们测试,可以使用IDE工具 下载链接:https://pan.baidu.com/s/1bpo5mqj 掌握: #1. 测试+链接 ...