zoukankan      html  css  js  c++  java
  • 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

  • 相关阅读:
    抚琴弹唱东流水
    借点阳光给你
    日月成双行影单
    一夜飘雪入冬来
    悼念钱学森
    我的青春谁作主
    重游望江楼有感
    雪后暖阳
    满城尽添黄金装
    敢叫岁月不冬天
  • 原文地址:https://www.cnblogs.com/LyonLys/p/uva_11859_Lyon.html
Copyright © 2011-2022 走看看