Division Game UVA - 11859 Nim】的更多相关文章

Code: #include<cstdio> #include<algorithm> using namespace std; #define maxn 10005 int nums[maxn], prime[maxn], cnt, vis[maxn]; int main(){ //freopen("input.in","r",stdin); vis[1]=1; for(int i=2;i<maxn;++i){ if(!vis[i])…
把每一行m个数所有的素因子看做一堆,就把问题转化为n堆的Nim游戏. 然后预处理一下10000以内每个数素因数的个数,再根据书上的Bouton定理,计算一下n行素因数个数的异或和. 为0是先手必败局面,输出NO,否则输出YES #include <cstdio> #include <cmath> ; ]; int main() { //freopen("in.txt", "r", stdin); ; i <= maxp; i++) if…
题意:给定一个N*M的矩阵,每次可以选择同一行中的若干个数,把它们变成它们的质因子.问说先手的可否获胜. 同一行相当于1堆,数量就是所有数的质因子个数之和 #include <iostream> #include <cstdio> #include <algorithm> #include <cstring> #include <cmath> using namespace std; ; inline int read(){ ,f=; ;c=ge…
看题传送门 题目大意 有一个n * m的矩阵,每个元素均为2~10000之间的正整数,两个游戏者轮流操作.每次可选一行中的1个或者多个大于1的整数把它们中的每个数都变成它的某个真因子,比如12可以变成1,2,3,4,5.不能操作的输,也就是说,谁在操作之前,矩阵中的所有数是1,则输.题目要求判断第一个人是否能获胜. 初试博弈论.觉得挺好玩的~^ ^ 本题可转化为Nim游戏. 题目要求让一个数变为它的真因子,等价于拿掉一个或者多个它的素因子.(12拿掉素因子2变为6,拿掉素因子3变为4,拿掉两个素…
Ugly Numbers Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 21918 Accepted: 9788 Description Ugly numbers are numbers whose only prime factors are 2, 3 or 5. The sequence 1, 2, 3, 4, 5, 6, 8, 9, 10, 12, - shows the first 10 ugly numbers.…
                                                                             Ugly Numbers Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 19952   Accepted: 8856 Description Ugly numbers are numbers whose only prime factors are 2, 3 or 5.…
题目链接:http://poj.org/problem?id=1338 Ugly Numbers Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 21920   Accepted: 9789 Description Ugly numbers are numbers whose only prime factors are 2, 3 or 5. The sequence 1, 2, 3, 4, 5, 6, 8, 9, 10,…
任意门:http://poj.org/problem?id=1320 Street Numbers Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 3181   Accepted: 1776 Description A computer programmer lives in a street with houses numbered consecutively (from 1) down one side of the…
传送门 Street Numbers Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 2529   Accepted: 1406 Description A computer programmer lives in a street with houses numbered consecutively (from 1) down one side of the street. Every evening she walks…
ID Codes Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 6229   Accepted: 3737 Description It is 2084 and the year of Big Brother has finally arrived, albeit a century late. In order to exercise greater control over its citizens and ther…