题解:

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

  分析一个堆的情况,打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. php关联不上mysql解决办法

      ## php无法关联mysql  php关联不上mysql解决办法: 尝试N多方法,需要的dll文件都复制了,依旧是不断提示: Fatal error: Call to undefined fun ...

  2. 主机win10与虚拟机ubuntu14.04通信

    主机是笔记本win10系统,在virtualbox虚拟机里面安装了ubuntu14.04系统,现在想让它们互联互通. 我的笔记本是通过路由器无线连接接入的互联网,设置了固定ip:192.168.0.4 ...

  3. 一个好用的PHP验证码类

    分享一个好用的php验证码类,包括调用示例. 说明: 如果不适用指定的字体,那么就用imagestring()函数,如果需要遇到指定的字体,就要用到imagettftext()函数.字体的位置在C盘下 ...

  4. openerp模块收藏 基于Lodop的报表打印模块(转载)

    基于Lodop的报表打印模块 原文:http://shine-it.net/index.php/topic,7397.0.html 前段时间写了个小模块,来解决OE中报表打印不方便的问题.借鉴了 @b ...

  5. 飞行器的Pitch Yaw Roll概念图解

    前进方向为Z轴 Pitch 升降 绕X轴  对应常见Φ(phi)角: Yaw 偏航 绕Y轴 对应常见θ(theta)角: Roll 翻滚 绕Z轴 对应常见φ(psi)角: 对应表: 参考网址NASA: ...

  6. exec 和 source的区别

    source 就是让 script 在当前 shell 内执行.而不是产生一个 sub-shell 来执行.由exec 也是让 script 在同一个行程上执行,但是原有行程则被结束了. source ...

  7. C# 发邮件类可发送附件

    using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Ne ...

  8. ActiveMQ之jmscorrelationid与selector

    前面讲过JMSCorrelationID主要是用来关联多个Message,例如需要回复一个消息的时候,通常把回复的消息的JMSCorrelationID设置为原来消息的ID.在下面这个例子中,创建了三 ...

  9. Javascript实例:求数组中最大、最小值及下标

    题目:定义一个数组,并给出7个整数,求该数组中的最大值,及最大值下标,最小值及最小值下标.<script type="text/javascript">//定义一个数组 ...

  10. BLOB或TEXT字段使用散列值和前缀索引优化提高查询速度

    1.创建表,存储引擎为myisam,对大文本字段blob使用MD5函数建立一个散列值 create table t2(id varchar(60), content blob, hash_value ...