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

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

  1. #include<iostream>
  2. #include<map>
  3. #include<iostream>
  4. #include<cstring>
  5. #include<cstdio>
  6. #include<set>
  7. #include<vector>
  8. #include<queue>
  9. #include<stack>
  10. #include<algorithm>
  11. using namespace std;
  12. typedef long long ll;
  13. const int N = 1e5+5;
  14. #define MS(x,y) memset(x,y,sizeof(x))
  15. #define MP(x, y) make_pair(x, y)
  16. const int INF = 0x3f3f3f3f;
  17. int prime[N];
  18. int isprime[N]; int tot = 0;
  19. int n;
  20. map<int, int> mp;
  21. map<int, int> dp;
  22. map<int, int> ::iterator it;
  23. int solve(int x){
  24. if(dp.find(x) != dp.end()) return dp[x];
  25. int mex[35];
  26. MS(mex, 0);
  27. for(int i = 0; x >> i; ++i) {
  28. int tt = solve( (x >> (i + 1)) | ( ((1<<i) - 1) & x ) );
  29. mex[tt] ++;
  30. }
  31. for(int i = 0; i < 35; ++i) {
  32. if(!mex[i]) {
  33. dp[x] = i;
  34. return i;
  35. }
  36. }
  37. }
  38. int main() {
  39. for(int i = 2; i < N; ++i) {
  40. if(isprime[i] == 0) {
  41. prime[++tot] = i;
  42. for(int j = 2*i; j < N; j += i) {
  43. isprime[j] ++;
  44. }
  45. }
  46. }
  47. while(~scanf("%d", &n)) {
  48. mp.clear();
  49. for(int i = 0; i < n; ++i) {
  50. int a; scanf("%d", &a);
  51. for(int j = 1; j <= tot; ++j) {
  52. if(a % prime[j] == 0) {
  53. int cnt = 0;
  54. while(a % prime[j] == 0) a /= prime[j], cnt ++;
  55. mp[prime[j]] |= 1<<(cnt-1);
  56. if(a == 1) break;
  57. }
  58. }
  59. if(a != 1) {
  60. mp[a] |= 1;
  61. }
  62. }
  63. int ans = 0;
  64. for(it = mp.begin(); it != mp.end(); ++it) {
  65. dp.clear();
  66. ans ^= solve(it -> second);
  67. }
  68. if(ans) printf("Mojtaba\n");
  69. else printf("Arpa\n");
  70. }
  71. return 0;
  72. }

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. Spring单元测试

    1.基于AbstractDependencyInjectionSpringContextTests Spring的单元测试可以使用AbstractDependencyInjectionSpringCo ...

  2. Go解析写死的json

    func TestAliAfpAdapter_AskAd_Banner(t *testing.T) { apiData := getApiData() apiData.ApiInfo.ApiPosit ...

  3. 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 ...

  4. 导入sass文件

    4导入sass文件 sass的@import规则在生成css文件时就把相关文件导入进来.这意味着所有相关的样式被归纳到了同一个css文件中,而无需发起额外的下载请求. 1 sass局部文件的文件名以下 ...

  5. JQuery坑,说说哪些大家都踩过的坑

    1 乱用选择器 坑人指数:200 JQuery选择器调用代价很大,反复调用效率更低.应采用缓存对象的方法或采用链式调用的方式. //错误的写法 $("#button").click ...

  6. Oracle批量操作数据库

    1:批量插入 <insert id="insertBatch" parameterType="Java.util.List" > insert in ...

  7. linux 管理权限

    linux 管理权限 linux 文件 权限 1.使用 ls -l 命令 执行结果如下(/var/log) : drwxr-x--- 2 root adm 4096 2013-08-07 11:03 ...

  8. web端表格测试用例

    表格测试: 表格内容列表排序功能是否正常每一栏的宽度是否足够宽,表格里的文字是否都有折行?是否有因为某一格的内容太多,而将整行的内容拉长?表格是否能左(右)添加(删除)列,表格是否能上(下)添加(删除 ...

  9. eclipse中创建一个maven项目

    1.什么是Maven Apache Maven 是一个项目管理和整合工具.基于工程对象模型(POM)的概念,通过一个中央信息管理模块,Maven 能够管理项目的构建.报告和文档. Maven工程结构和 ...

  10. maven指定部署的服务器类型

    <!-- 指定部署的服务器类型 --> <plugins> <!-- <plugin> <groupId>org.apache.tomcat.ma ...