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 ...
随机推荐
- Spring单元测试
1.基于AbstractDependencyInjectionSpringContextTests Spring的单元测试可以使用AbstractDependencyInjectionSpringCo ...
- Go解析写死的json
func TestAliAfpAdapter_AskAd_Banner(t *testing.T) { apiData := getApiData() apiData.ApiInfo.ApiPosit ...
- is there any way to stop auto block
shadowsocks出现错误日志 tail /var/log/ssserver.log 2017-07-02 12:36:31 ERROR: block all requests from 10.4 ...
- 导入sass文件
4导入sass文件 sass的@import规则在生成css文件时就把相关文件导入进来.这意味着所有相关的样式被归纳到了同一个css文件中,而无需发起额外的下载请求. 1 sass局部文件的文件名以下 ...
- JQuery坑,说说哪些大家都踩过的坑
1 乱用选择器 坑人指数:200 JQuery选择器调用代价很大,反复调用效率更低.应采用缓存对象的方法或采用链式调用的方式. //错误的写法 $("#button").click ...
- Oracle批量操作数据库
1:批量插入 <insert id="insertBatch" parameterType="Java.util.List" > insert in ...
- linux 管理权限
linux 管理权限 linux 文件 权限 1.使用 ls -l 命令 执行结果如下(/var/log) : drwxr-x--- 2 root adm 4096 2013-08-07 11:03 ...
- web端表格测试用例
表格测试: 表格内容列表排序功能是否正常每一栏的宽度是否足够宽,表格里的文字是否都有折行?是否有因为某一格的内容太多,而将整行的内容拉长?表格是否能左(右)添加(删除)列,表格是否能上(下)添加(删除 ...
- eclipse中创建一个maven项目
1.什么是Maven Apache Maven 是一个项目管理和整合工具.基于工程对象模型(POM)的概念,通过一个中央信息管理模块,Maven 能够管理项目的构建.报告和文档. Maven工程结构和 ...
- maven指定部署的服务器类型
<!-- 指定部署的服务器类型 --> <plugins> <!-- <plugin> <groupId>org.apache.tomcat.ma ...