• CF15C. Industrial Nim


     1 /*
     2  CF15C. Industrial Nim
     3  http://codeforces.com/problemset/problem/15/C
     4  数论 博弈论 尼姆博弈
     5 
     6  典型的尼姆博弈,答案就是所有数的异或值
     7  然而在1e16的数据范围下直接异或肯定会T
     8  考虑以一个能被4整除的数开始的连续4n个数的异或和为0
     9  所以只需找到其余的值,做异或便得到答案
    10  */
    11 #include <cstdio>
    12 #include <cmath>
    13 #include <algorithm>
    14 using namespace std;
    15 long long num[20];
    16 int cnt;
    17 int main()
    18 {
    19     int n;
    20     long long k,x;
    21     long long ans=0LL;
    22     scanf("%d",&n);
    23     for(int i=1;i<=n;i++)
    24     {
    25         cnt=0;
    26         scanf("%lld%lld",&x,&k);
    27         long long r=x+k-1LL;
    28         long long l=x;
    29         while(l%4!=0 && l<=r)
    30             num[++cnt]=l++;
    31         l--;
    32         while(r%4!=3 && l<r)
    33             num[++cnt]=r--;
    34         for(int j=1;j<=cnt;j++)
    35             ans^=num[j];
    36     }
    37     if(ans==0LL)
    38         printf("bolik
    ");
    39     else
    40         printf("tolik
    ");
    41     return 0;
    42 }
  • 相关阅读:
    skill:极角排序
    skill:树的重心
    [CF1091F](New Year and the Mallard Expedition)
    2018九省联考(SHOI2018)
    陷入僵局?
    2333
    雨后天晴
    听说我首次抢到食堂最早的馄饨
    难题做不动
    成绩出来了?
  • 原文地址:https://www.cnblogs.com/BBBob/p/6627371.html
Copyright © 2020-2023  润新知