山东省第七届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(最小公倍数)是很容易的事,现在我遇到了 ...
随机推荐
- java文件来演示如何访问MySQL数据库
java文件来演示如何访问MySQL数据库. 注:在命令行或用一个SQL的前端软件创建Database. 先创建数据库: CREATE DATABASE SCUTCS; 接着,创建表: CREATE ...
- Sql Server海量数据插入
目录 1.前言 2.BULK INSERT 3.简单示例 前言 由于昨天接到一个客户反馈导出数据卡死的问题,于是决定今天模拟一下千万级的数据,然后傻傻的等待插入数据了半天...... 对于海量数据,上 ...
- Method Swizzling
学习博客: http://www.cocoachina.com/ios/20160121/15076.html (这个作者太牛了,写了我一直想知道的类簇的swizz方法) 一. 一般的swizz 先给 ...
- C/C++源代码从写完到运行发生了什么
有时候经常听到一些不明觉厉的词语,什么编译啊链接啊语义分析啊的,就找书来看看,把笔记画成了图: 编译器干了些啥呢,如下图: 参考书:<程序员的自我修养——链接.装载与库>,<深入理解 ...
- tomcat404报错解决
本地启动tomcat,不报错.也可正常打开http://localhost:8080 但是eclipse中启动tomcat不报错.但是打开http://localhost:8080时报404 思考,原 ...
- CSS 的定位方式和含义
CSS 的定位方式和含义 总结一下 CSS 的定位方式.CSS 的定位 position 是处理页面布局时非常重要的属性. CSS 中有 3 种基本的定位机制:普通流.浮动和绝对定位. 在没有指定的情 ...
- ubifs概述
UBIFS无排序区块图像文件系统(Unsorted Block Image File System, UBIFS)是用于固态存储设备上,并与LogFS相互竞争,作为JFFS2的后继文件系统之一.真正开 ...
- storm学习
一 storm 相关术语 . Nimbus storm 集群主节点,负责资源分配和任务调度.(相当于namenode) . supervisor storm集群工作节点,接受Nimbu分配任务,管理w ...
- delphi 弹出选择目录窗口
if not SelectDirectory( '请选择输出文件路径','/',directory) then begin Exit; end; 使用SelectDirectory函数注意要在use下 ...
- 3.Java Script 类型
true: null==undefinedfalse: null===undefined