zoukankan      html  css  js  c++  java
  • 【ZJOI2017 Round1练习】D8T3 stone(Nim游戏)

    题意:

    思路:与其类似的题是HDU5996

    HDU5996为判定性问题,稍加改动就可以用来统计方案数

     1 var a:array[1..1000000]of longint;
     2     v,cas,i,j,ans,tmp,n,s,k:longint;
     3 begin
     4  assign(input,'stone.in'); reset(input);
     5  assign(output,'stone.out'); rewrite(output);
     6  readln(cas);
     7  for v:=1 to cas do
     8  begin
     9   readln(n); s:=0; k:=0;
    10   for i:=1 to n do
    11    for j:=1 to 1<<(i-1) do
    12    begin
    13     inc(k); read(a[k]);
    14     if (n-i) mod 2=0 then s:=s xor a[k];
    15    end;
    16   //writeln(s);
    17   ans:=0; k:=0;
    18   for i:=1 to n do
    19    for j:=1 to 1<<(i-1) do
    20    begin
    21     inc(k);
    22     if (n-i) mod 2=0 then
    23     begin
    24      tmp:=0 xor (s xor a[k]);
    25      if tmp<a[k] then
    26      begin
    27       if i=n then inc(ans)
    28        else ans:=ans+2;
    29      end;
    30      if (i>1)and(tmp>a[k])and((k>>1)>0)and
    31        (a[k>>1]>=tmp-a[k]) then inc(ans);
    32     end;
    33    end;
    34   writeln(ans);
    35 
    36  end;
    37 
    38  close(input);
    39  close(output);
    40 end.
  • 相关阅读:
    Probability theory
    python Memo
    numpy 札记
    linux LVM 逻辑卷
    关于TF-IDF的一些见解
    Python之list、dict、np等常用数值运算
    Python之matplotlib绘图
    Python之打开网页
    Python之获取地址经纬度
    两台电脑直接共享文件
  • 原文地址:https://www.cnblogs.com/myx12345/p/6533893.html
Copyright © 2011-2022 走看看