• 博客园logo
  • 会员
  • 众包
  • 新闻
  • 博问
  • 闪存
  • 赞助商
  • HarmonyOS
  • Chat2DB
    • 搜索
      所有博客
    • 搜索
      当前博客
  • 写随笔 我的博客 短消息 简洁模式
    用户头像
    我的博客 我的园子 账号设置 会员中心 简洁模式 ... 退出登录
    注册 登录
LyonLys
愿意在角落唱沙哑的歌 再大声也都是给你 请用心听 不要说话 Contact me via E-mail: lyon.lys@gmail.com
博客园    首页    新随笔    联系   管理    订阅  订阅

uva 11859 Division Game

UVA 11859

  看书看到博弈的部分了,然后就做一下这题。我们可以把因数个数看成石子,于是这题就变成了一个常规的Nim游戏了。

  博弈好像挺好玩的,Bouton定理的证明也基本看懂,有空切一下博弈玩玩好像听不错的样子。

代码如下:

 1 #include <cstring>
 2 #include <iostream>
 3 #include <algorithm>
 4 #include <cstdio>
 5 
 6 using namespace std;
 7 
 8 const int N = 11111;
 9 int pcnt[N];
10 
11 void PRE() {
12     for (int i = 2; i < N; i++) {
13         if (pcnt[i]) continue;
14         int t = i;
15         while (t < N) {
16             for (int j = t; j < N; j += t) {
17                 pcnt[j]++;
18             }
19             t *= i;
20         }
21     }
22 }
23 
24 int main() {
25     int n, m, x, T;
26     PRE();
27     scanf("%d", &T);
28     for (int cas = 1; cas <= T; cas++) {
29         scanf("%d%d", &n, &m);
30         int ans = 0;
31         for (int i = 0; i < n; i++) {
32             int rsum = 0;
33             for (int j = 0; j < m; j++) {
34                 scanf("%d", &x);
35                 rsum += pcnt[x];
36             }
37             ans ^= rsum;
38             //cout << rsum << endl;
39         }
40         printf("Case #%d: ", cas);
41         if (ans) puts("YES");
42         else puts("NO");
43     }
44     return 0;
45 }
View Code

 

——written by Lyon

posted @ 2013-08-03 10:32  LyonLys  阅读(216)  评论(0)    收藏  举报
刷新页面返回顶部
博客园  ©  2004-2025
浙公网安备 33010602011771号 浙ICP备2021040463号-3