Codeforces Round #432 Div. 1 C. Arpa and a game with Mojtaba
首先容易想到,每种素数是独立的,相互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的更多相关文章
- 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 ...
- Codeforces Round #432 (Div. 1) B. Arpa and a list of numbers
qtmd的复习pat,老子不想看了,还不如练几道cf 这题首先可以很容易想到讨论最后的共因子为素数 这个素数太多了,1-1e6之间的素数 复杂度爆炸 所以使用了前缀和,对于每个素数k的每个小区间 (k ...
- 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> # ...
- 【前缀和】【枚举倍数】 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 ...
- 【推导】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为上顶点.那么其外接圆圆心即 ...
- 【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 ...
- 【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不能为一条直线.否则无解. 共圆之后 ...
- 【Codeforces Round #432 (Div. 1) B】Arpa and a list of numbers
[链接]h在这里写链接 [题意] 定义bad list是一个非空的.最大公约数为1的序列.给定一个序列,有两种操作:花费x将一个元素删除.花费y将一个元素加1,问你将这个序列变为good list所需 ...
- 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 ...
随机推荐
- Linux命令pmap
jmap可以查看Java程序的堆内存使用情况,pmap可以查看Linux上运行的进程的内存使用情况. 查看Linux上运行的进程的内存使用情况,可以使用jmap,top,ps命令. top命令本身也比 ...
- Timer类的schedule和scheduleAtFixedRate 简单应用
Timer类可以用作定时任务,主要的方法有schedule和scheduleAtFixedRate. schedule(TimerTask task, Date time) 安排在指定的时间执行指定的 ...
- HDU 4349 Xiao Ming's Hope [Lucas定理 二进制]
这种题面真是够了......@小明 题意:the number of odd numbers of C(n,0),C(n,1),C(n,2)...C(n,n). 奇数...就是mod 2=1啊 用Lu ...
- HDU 4333 Revolving Digits [扩展KMP]【学习笔记】
题意:给一个数字,每一次把它的最后一位拿到最前面,一直那样下去,分别求形成的数字小于,等于和大于原来数的个数. SAM乱搞失败 当然要先变SS了 然后考虑每个后缀前长为n个字符,把它跟S比较就行了 如 ...
- Git点滴记录
合并多个commit记录 假设我们当前有三个commit信息,现在要将commit hash为 23f92c 和 409978 合并 //git rebase -i HEAD~3 那么我们可以使用 r ...
- php get_called_class()函数与get_class()函数的区别
get_class (): 获取当前调用方法的类名: get_called_class():获取静态绑定后的类名: class Foo{ public function test(){ var_dum ...
- CentOS下安装go语言编译环境
1.下载Go语言的安装包 这里给大家一个百度的分享连接http://pan.baidu.com/s/1qY3xPaG下载到CentOS的系统之中 $ tar -xzf go1.5.2.linux-xx ...
- PyCharm安装及使用
搭建环境 1.win10_X64,其他Win版本也可以. 2.PyCharm版本:Professional-2016.2.3. 搭建准备 1.到PyCharm官网下载PyCharm安装包. Dow ...
- python3基础入门-知识点简记
1.基础语法 编码.标识符.保留字.注释.行与缩进... 2.变量类型 (1)Python3有6个标准的数据类型: Numbers(数字) 数字数据类型用于存储数值 不可改变的数据类型 可细分为 ...
- 【学习笔记】Hibernate关联映射(Y2-1-6)
Hibernate关联映射 关联映射就是将关联关系映射到数据库里,在对象模型中就是一个或多个引用. 1.单向多对一关联 准备数据库 部门表和员工表 其中部门表有两列 部门编号和名称 员工表有三列 员工 ...