题解:

  将一个数的指数看着一个堆,问题变成这些堆的异或值

  分析一个堆的情况,打SG表。

#include<stdio.h>
#include<string.h>
char sg[]; char getsg(int x)
{
if(sg[x]>=) return sg[x];
bool hash[]= {};
for(int i=; i<; i++)
{
if(x&(<<i))
{
int t=i+,tmp=x;
while(t<=)
{
if(tmp&(<<(t-))) tmp-=<<(t-);
t+=i+;
}
hash[getsg(tmp)]=;
}
//printf("%d %d\n",i,getsg((1<<i)-1));
}
int i=;
while(hash[i]) i++;
return sg[x]=i;
} int main()
{
memset(sg,-,sizeof(sg));
sg[]=;
int i=;
getsg((<<i)-);
for(int i=; i<=; i++)
{
printf("%d %d\n",i,sg[(<<i)-]);
}
return ;
}

打表找规律

CF 317D Game with Powers的更多相关文章

  1. CF 305C ——Ivan and Powers of Two——————【数学】

    Ivan and Powers of Two time limit per test 1 second memory limit per test 256 megabytes input standa ...

  2. CF 1095C Powers Of Two(二进制拆分)

    A positive integer xx is called a power of two if it can be represented as x=2y, where y is a non-ne ...

  3. CF 1095C Powers Of Two

    题目连接:http://codeforces.com/problemset/problem/1095/C 题目: C. Powers Of Two time limit per test 4 seco ...

  4. CF 702B Powers of Two(暴力)

    题目链接: 传送门 Devu and Partitioning of the Array time limit per test:3 second     memory limit per test: ...

  5. CF 622F The Sum of the k-th Powers——拉格朗日插值

    题目:http://codeforces.com/problemset/problem/622/F 发现 sigma(i=1~n) i 是一个二次的多项式( (1+n)*n/2 ),sigma(i=1 ...

  6. CF 622 F The Sum of the k-th Powers —— 拉格朗日插值

    题目:http://codeforces.com/contest/622/problem/F 设 f(x) = 1^k + 2^k + ... + n^k 则 f(x) - f(x-1) = x^k ...

  7. ORA-00494: enqueue [CF] held for too long (more than 900 seconds) by 'inst 1, osid 5166'

    凌晨收到同事电话,反馈应用程序访问Oracle数据库时报错,当时现场现象确认: 1. 应用程序访问不了数据库,使用SQL Developer测试发现访问不了数据库.报ORA-12570 TNS:pac ...

  8. cf之路,1,Codeforces Round #345 (Div. 2)

     cf之路,1,Codeforces Round #345 (Div. 2) ps:昨天第一次参加cf比赛,比赛之前为了熟悉下cf比赛题目的难度.所以做了round#345连试试水的深浅.....   ...

  9. cf Round 613

    A.Peter and Snow Blower(计算几何) 给定一个点和一个多边形,求出这个多边形绕这个点旋转一圈后形成的面积.保证这个点不在多边形内. 画个图能明白 这个图形是一个圆环,那么就是这个 ...

随机推荐

  1. 查询sql语句所花时间

    --1:下面这种是SQL Server中比较简单的查询SQL语句执行时间方法,通过查询前的时间和查询后的时间差来计算的: declare @begin_date datetime declare @e ...

  2. 解析php开发中的中文编码问题

    其实php开发中的中文编码并没有想像的那么复杂,虽然定位和解决问题没有定规,各种运行环境也各不尽然,但后面的原理是一样的. 了解字符集的知识是解决字符问题的基础. PHP程序设计中中文编码问题曾经困扰 ...

  3. oracle11g RAC添加节点

    OS: [root@rac ~]# more /etc/oracle-releaseOracle Linux Server release 5.7 DB: SQL> SELECT * FROM ...

  4. ubuntu 12.04版本出现界面终端打开broken pipe,但是tty1这些可以。

    sudo apt-get remove xserver-xorg sudo apt-get install xserver-xorg

  5. PHP正则表达式的逆向引用与子模式 php preg_replace应用

    mixed preg_replace ( mixed pattern, mixed replacement, mixed subject [, int limit]) 功能 在 subject 中搜索 ...

  6. php protected只能被继承,不可以在实例中调用,parent::调用父类(子类函数的重载对父类的函数没有影响)

    <?php class a { private function fun1(){ echo 'a1'; } //protected 可以被继承,但是只能在子类中使用,不能被实例化调用 prote ...

  7. (ACM)C++ STL 训练(第一天)

    因为老师说ACM考的是纯C++,所以打算抛弃VS的VC++不用了,针对纯C++的编译器有Intel Compiler(不过要钱),MinGw(个人用的),当然还有微软的VC++ 编译器,IDE你们可以 ...

  8. java之redis篇(spring-data-redis整合)

    <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/20 ...

  9. Fibonacci数

    Fibonacci数 时间限制:3000 ms  |  内存限制:65535 KB 难度:1   描述 无穷数列1,1,2,3,5,8,13,21,34,55...称为Fibonacci数列,它可以递 ...

  10. std::function赋值的几种方法

    定义: #include <functional> std::function<void(const QString&)> myPrintFunction; 函数指针 ...