Codeforces 850C E. Arpa and a game with Mojtaba
对每个数统计其素数因子各次方数的数,然后通过y = (x>>i) | (x&((1<<(i-1))-1)) 模拟delete x and add
to the list 操作,用grund函数将每个因子的情况映射为NIM问题中一个堆的情况,再按NIM问题的求解方法求解
参考链接 https://www.topcoder.com/community/data-science/data-science-tutorials/algorithm-games/
#include<bits/stdc++.h>
using namespace std;
map<int,int> mp;
unordered_map<int,int> ttmp;
int n,tmp,y;
int grund(int x){
if(ttmp.count(x)) return ttmp[x];
unordered_set<int> s;
for(int i = ;i<=;i++){
y = (x>>i) | (x&((<<(i-))-));
if(y!=x) s.insert(grund(y));
} int ans = ;
while(s.count(ans)) ans++;
return ttmp[x] = ans;
}
int main(){
cin>>n;
for(int i = ;i<n;i++){
cin>>tmp;
for(int j = ;j*j<=tmp;j++){
if(tmp%j == ){
int cnt = ;
while(tmp%j == ){
tmp/=j;
cnt++;
}
mp[j] |= (<<cnt-);
}
}
if(tmp>) mp[tmp] |= ;
}
int ans = ;
ttmp[] = ;
for(auto t : mp){
ans^=grund(t.second);
}
cout<<(ans?"Mojtaba":"Arpa")<<endl;
return ;
}
Codeforces 850C E. Arpa and a game with Mojtaba的更多相关文章
- Codeforces 850C Arpa and a game with Mojtaba
题意:给定一个正整数序列,两人轮流对这个数列进行如下修改:选取一个素数p和一个整数k将序列中能整除p^k的数除以p^k,问谁有必胜策略. 借此复习一下sg函数吧,sg(x) = mex ( sg(y) ...
- 【codeforces 742C】Arpa's loud Owf and Mehrdad's evil plan
time limit per test1 second memory limit per test256 megabytes inputstandard input outputstandard ou ...
- 【codeforces 742B】Arpa’s obvious problem and Mehrdad’s terrible solution
time limit per test1 second memory limit per test256 megabytes inputstandard input outputstandard ou ...
- 【codeforces 742A】Arpa’s hard exam and Mehrdad’s naive cheat
time limit per test1 second memory limit per test256 megabytes inputstandard input outputstandard ou ...
- 【42.86%】【codeforces 742D】Arpa's weak amphitheater and Mehrdad's valuable Hoses
time limit per test1 second memory limit per test256 megabytes inputstandard input outputstandard ou ...
- Codeforces 741B:Arpa's weak amphitheater and Mehrdad's valuable Hoses(01背包+并查集)
http://codeforces.com/contest/741/problem/B 题意:有 n 个人,每个人有一个花费 w[i] 和价值 b[i],给出 m 条边,代表第 i 和 j 个人是一个 ...
- Codeforces 741A:Arpa's loud Owf and Mehrdad's evil plan(LCM+思维)
http://codeforces.com/problemset/problem/741/A 题意:有N个人,第 i 个人有一个 a[i],意味着第 i 个人可以打电话给第 a[i] 个人,所以如果第 ...
- Codeforces Round #432 Div. 1 C. Arpa and a game with Mojtaba
首先容易想到,每种素数是独立的,相互sg就行了 对于一种素数来说,按照的朴素的mex没法做... 所以题解的简化就是数位化 多个数同时含有的满参数因子由于在博弈中一同变化的,让他们等于相当于,那么这样 ...
- Codefroces 850C Arpa and a game with Mojtaba
Description两个人Van♂游戏.给出$n$个正整数$ai$两人轮流操作,每次选出一个素数$p$和一个幂数$k$,选择的前提为该$n$个数中有$p^{k}$的倍数.接着将所有的$p^{k}$的 ...
随机推荐
- Oracle客户端下载地址
https://www.oracle.com/database/technologies/instant-client/downloads.html
- 国内强大的API接口文档写作网站showdoc
传送门:https://www.showdoc.cc/ 思思今天使用了一下,真是非常方便,瞬间爱上呀,哈哈. 赶紧去试试吧...
- jQuery跨域调用WebService
jQuery跨域调用WebService举例html: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN&qu ...
- 比较SSO协议: WS-Fed, SAML, and OAuth
真实比喻 在我们获得技术之前,让我们用完全非技术性的东西来解决这个问题.作为工程师,我们非常注重将事情分解为组件和流程.这有助于我们了解事情,以便我们可以排除故障或构建复杂的系统.当你去机场登机时,你 ...
- CommMonitor10.0.3串口过滤工具(serial port monitor)
CommMonitor 串行端口监视精灵是用于RS232 / RS422 / RS485端口监控的专业强大的系统实用程序软件.CommMonitor监视显示,记录和分析系统中的所有串行端口活动.这是 ...
- Xena L23网络测试仪Valkyrie使用技巧100例,目录
Xena L23网络测试仪Valkyrie使用技巧100例,先写个目录 100例,会不会有点多,写不完... ^_^ 第1次编辑于2019-11-27 22:05:52, Evan YE. 编号 标题 ...
- 侯捷C++内存管理(一)
1.Overview 2.内存分配的每一层面 3.四个层面的基本用法 1).对比一下: 4.基本构件之一newdelete expression(上) ——>new和operator new.m ...
- 【POJ - 3268 】Silver Cow Party (最短路 Dijkstra算法)
Silver Cow Party Descriptions 给出n个点和m条边,接着是m条边,代表从牛a到牛b需要花费c时间,现在所有牛要到牛x那里去参加聚会,并且所有牛参加聚会后还要回来,给你牛x, ...
- 给引入页面的js和css资源加上版本号,防止浏览器缓存资源
最近因为在做前端开发的相关工作,每次发布新版本以后,不到5分钟,测试童鞋一个接一个的抱怨说BUG根本就没有修改,这个时候你说的最多的话就是“清缓存!!清页面缓存!!你没有清缓存!!你清理了页面缓存就对 ...
- 最新 金蝶软件java校招面经 (含整理过的面试题大全)
从6月到10月,经过4个月努力和坚持,自己有幸拿到了网易雷火.京东.去哪儿.金蝶软件等10家互联网公司的校招Offer,因为某些自身原因最终选择了金蝶软件.6.7月主要是做系统复习.项目复盘.Leet ...