UVA 11859 - Division Game (SG博弈)
来源:互联网 发布:自己能干淘宝秒杀群吗 编辑:程序博客网 时间:2024/06/05 04:05
题目地址:http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&category=226&problem=2959&mosmsg=Submission+received+with+ID+12234894
题意:给你n*m的矩阵,两个人轮流操作,每个人可以选一行中至少一个大于1的数变成它的真因子,直到一个人不能操作为输。(即:全为1)
题解:考虑每一个数的素因子个数,比如12=2*2*3,包含三个素因子,可以拿掉三次,所以可以装换为Nim游戏。
AC代码:
#include <iostream>#include <cstdio>#include <cstring>#include <string>#include <cstdlib>#include <cmath>#include <vector>#include <list>#include <deque>#include <queue>#include <iterator>#include <stack>#include <map>#include <set>#include <algorithm>#include <cctype>#include <ctime>using namespace std;typedef long long LL;const int N=1005;const double eps=1e-6;const int M=1<<12;const int INF=0x3f3f3f3f;const double PI=acos(-1.0);int yinzi(int p){ int xh=0; for(int i=2;i*i<=p;i++) { while(p%i==0) { xh++; p/=i; } } if(p>1) xh++; return xh;}int main(){ int i,j,T; int ca=0; scanf("%d",&T); while(T--) { int a,t=0; int n,m; scanf("%d%d",&n,&m); for(i=0;i<n;i++) { int sum=0; for(j=0;j<m;j++) { scanf("%d",&a); sum+=yinzi(a);//因子不包括1 } t=t^sum; } printf("Case #%d: ",++ca); if(t==0) printf("NO\n"); else printf("YES\n"); } return 0;}/*52 22 32 32 24 98 53 32 3 53 9 28 8 33 33 4 54 5 65 6 72 34 5 67 8 9*/
- UVA 11859 - Division Game (SG博弈)
- UVA 11859 Division Game (Nim博弈)
- UVA 11859 - Division Game
- UVA - 11859 Division Game
- uva 11859 - Division Game(Nim)
- uva 1378 A Funny Stone Game (博弈-SG)
- uva 1378 - A Funny Stone Game sg博弈
- UVa 12293 Box Game(博弈,SG函数)
- UVA 11859 - Division Game(Nim游戏)
- 【POJ2311】Cutting Game-SG博弈
- uva 1378 A Funny Stone Game 博弈/组合游戏 sg定理
- UVA 11249 - Game(博弈)
- Hackerrank Week of Code 25 Stone Division(SG 博弈)
- hdu1851_A Simple Game博弈—SG函数
- hdu2873 Bomb Game 二维SG博弈
- 【lightOJ】 Partitioning Game (博弈,sg函数)
- 【lightOJ】 Again Stone Game (博弈,SG函数)
- POJ_P2311 Cutting Game(博弈+SG函数)
- 在使用zbar这个开源库时从相册读取二维码
- Spring的理解
- TCP/IP详解学习笔记(5)-IP选路,动态选路,和一些细节
- lua源代码解析
- struts.xml配置详解
- UVA 11859 - Division Game (SG博弈)
- web.xml
- GVIM配置
- zoj 2974 Just Pour the Water 矩阵
- 二分法查表 算法
- Tomcat部署web项目
- 用Java+JDOM写的RSS阅读软件
- applicationContext.xml
- TCP/IP详解学习笔记(4)-ICMP协议,ping和Traceroute