山东省第七届ACM省赛------Triple Nim
Triple Nim
Time Limit: 2000MS Memory limit: 65536K
题目描述
Alice and Bob are always playing all kinds of Nim games and Alice always goes first. Here is the rule of Nim game:
There are some distinct heaps of stones. On each turn, two players should remove at least one stone from just one heap. Two player will remove stone one after another. The player who remove the last stone of the last heap will win.
Alice always wins and Bob is very unhappy. So he decides to make a game which Alice will never win. He begins a game called “Triple Nim”, which is the Nim game with three heaps of stones. He’s good at Nim game but bad as math. With exactly N stones,
how many ways can he finish his target? Both Alice and Bob will play optimally.
输入
输出
示例输入
3
3
6
14
示例输出
0
1
4
提示
来源
题意
#include"stdio.h"
#include"string.h"
#include<iostream>
using namespace std;
long long s1(long long int n) //求一个数二进制1的个数
{
long long s=0;
while(n>>=1)
if(n&1)++s;
return s-1;
}
long long f[30]= {1};
void init() //打表
{
for(int i=1; i<30; i++)
f[i]=f[i-1]*3+1;
}
int main()
{
int N;
init();
cin>>N;
while(N--)
{
long long int n;
cin>>n;
if(n&1)printf("0\n");
else
{
long long int dd=s1(n)-1;
cout<<f[dd]<<endl;
}
}
return 0;
}
山东省第七届ACM省赛------Triple Nim的更多相关文章
- 山东省第七届ACM省赛------Memory Leak
Memory Leak Time Limit: 2000MS Memory limit: 131072K 题目描述 Memory Leak is a well-known kind of bug in ...
- 山东省第七届ACM省赛------Reversed Words
Reversed Words Time Limit: 2000MS Memory limit: 131072K 题目描述 Some aliens are learning English. They ...
- 山东省第七届ACM省赛------The Binding of Isaac
The Binding of Isaac Time Limit: 2000MS Memory limit: 65536K 题目描述 Ok, now I will introduce this game ...
- 山东省第七届ACM省赛------Fibonacci
Fibonacci Time Limit: 2000MS Memory limit: 131072K 题目描述 Fibonacci numbers are well-known as follow: ...
- 山东省第七届ACM省赛------Julyed
Julyed Time Limit: 2000MS Memory limit: 65536K 题目描述 Julyed is preparing for her CET-6. She has N wor ...
- 山东省第七届ACM省赛
ID Title Hint A Julyed 无 B Fibonacci 打表 C Proxy 最短路径 D Swiss-system tournament 归并排序 E The Binding of ...
- 山东省第十届ACM省赛参赛后的学期总结
5.11,5.12两天的济南之旅结束了,我也参加了人生中第一次正式的acm比赛,虽然是以友情队的身份,但是我依旧十分兴奋. 其实一直想写博客来增加自己的能力的,但是一直拖到现在,正赶上老师要求写一份总 ...
- Rectangles(第七届ACM省赛原题+最长上升子序列)
题目链接: http://acm.nyist.edu.cn/JudgeOnline/problem.php?pid=1255 描述 Given N (4 <= N <= 100) rec ...
- 山东理工大学第七届ACM校赛-LCM的个数 分类: 比赛 2015-06-26 10:37 18人阅读 评论(0) 收藏
LCM的个数 Time Limit: 1000ms Memory limit: 65536K 有疑问?点这里^_^ 题目描述 对于我们来说求两个数的LCM(最小公倍数)是很容易的事,现在我遇到了 ...
随机推荐
- 【运维工具】Git代码发布系统
引言 代码发布系统是互联网公司必备的运维系统,作用主要用户发布业务代码 到 业务服务器 为什么需要代码发布系统 有的同学可能说,我们公司服务器就那么一台,做个发布系统太麻烦了? 不认同这说法 发布系统 ...
- 总结Lvs、nginx、Haproxy
!!!! 参考的比较多,自己想法少 大神总结的比较好 ====>http://www.ha97.com/5646.html 特性 LVs Nginx Haproxy 工作层 四层(传输层) 七 ...
- 在Centos6下面安装Python3.4
yum源里头好像没有python3.4 在Python的官网下载Python3.4的源代码 然后: 安装依赖包: yum groupinstall "Development tools&qu ...
- php 入门1
一.php在引入文件和js引入文件的区别 1.php在引入文件是用代码控制,而js是通过标签的属性src引入: 2.php引入可以在引入下写代码,而js是不可以的 3.静态效果的js可以引入的时间,引 ...
- Jesse Livermore的21句投机至理名言
1.优秀的投机家们总是在等待,总是有耐心,等待着市场证实他们的判断.要记住,在市场本身的表现证实你的看法之前,不要完全相信你的判断. 2.要想在投机中赚到钱,就得买卖一开始就表现出利润的 ...
- 用BlazeMeter录制JMeter测试脚本
工具: 1,JMeter 2,Chrome 3,BlazeMeter 4,SwitchyOmega(如果需要代理) 步骤: 以上工具准备好以后就可以录制JMeter的测试脚本了, 在Chrome中点击 ...
- 使用T4模板生成代码的学习
之前做项目使用的都是Db First,直接在项目中添加Entity Framework,使用T4模板(T4模板引擎之基础入门)生成DAL BLL层等(T4模板是一个同事给的,也没有仔细研究,代码如下: ...
- jNotify:操作结果信息提示条
我们在提交表单后,通过Ajax响应后台返回结果,并在前台显示返回信息,jNotify能非常优雅的显示操作结果信息.jNotify是一款基于jQuery的信息提示插件,它支持操作成功.操作失败和操作提醒 ...
- delphi 弹出选择目录窗口
if not SelectDirectory( '请选择输出文件路径','/',directory) then begin Exit; end; 使用SelectDirectory函数注意要在use下 ...
- flex自适应小例子
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8&quo ...