UVa 11859 (Nim) Division Game

Source: Internet
Author: User

Consider all the elements of M in each row as a bunch, and turn the problem into N-Heap Nim games.

Then preprocessing the number of each number of factors within 10000, and then according to the Bouton theorem in the book, calculate the N-line factor because of the number of different or and.

0 is the initiator must lose the situation, output no, otherwise output yes

1#include <cstdio>2#include <cmath>3 4 Const intMAXP =10000;5 intF[maxp +Ten];6 7 intMain ()8 {9     //freopen ("In.txt", "R", stdin);Ten  One      for(inti =2; I <= Maxp; i++)if(!F[i]) A     { -         intt =i; -          while(T <=Maxp) the         { -              for(intj = t; J <= Maxp; J + = t) f[j]++; -T *=i; -         } +     } -  +     intT; Ascanf"%d", &T); at      for(intKase =1; Kase <= T; ++Kase) -     { -         intN, M; -scanf"%d%d", &n, &m); -         intXorsum =0; -          for(inti =0; I < n; i++) in         { -             intCNT =0; to              for(intj =0; J < M; J + +) +             { -                 intx; thescanf"%d", &x); *CNT + =F[x]; $             }Panax NotoginsengXorsum ^=CNT; -         } theprintf"Case #%d:%s\n", Kase, Xorsum?"YES":"NO"); +     } A  the     return 0; +}
code June

UVa 11859 (Nim) Division Game

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.