第七届 山东省ACM Triple Nim(找规律 待整理)
来源:互联网 发布:lp是什么意思网络用语 编辑:程序博客网 时间:2024/06/04 17:41
Triple Nim
Problem Description
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.
Input
Output
Example Input
33614
Example Output
014
Hint
Author
题意:给你n个石子,分成三堆,计算通过Nim博弈的规则使得对方不能获胜的方案数。
思路:打表找规律题,不解释。
参考网址:http://blog.csdn.net/huayunhualuo/article/details/51626212
#include <bits/stdc++.h>using namespace std;typedef long long LL;int main(){ int T; LL n; scanf("%d",&T); while(T--) { scanf("%lld",&n); if(n%2) printf("0\n"); else { int s = 0 ; while(n) { if(n%2) s++; n/=2; } LL ans = (LL(pow(3,s))-3)/6; printf("%lld\n",ans); } } return 0;}
- 第七届 山东省ACM Triple Nim(找规律 待整理)
- 山东省第七届ACM省赛------Triple Nim
- 山东省第七届ACM省赛 Triple Nim
- 第七届ACM山东省赛-G Triple Nim
- 2016山东省第七届acm省赛 G题Triple Nim
- 山东省第七届ACM大学生程序设计竞赛Triple Nim
- 第七届 山东省ACM Memory Leak(模拟 待整理)
- 山东省第八届 ACM 省赛 Quadrat (找规律)
- 山东第7届省赛 G Triple Nim 找规律
- 2013年山东省第四届ACM大学生程序设计竞赛-Alice and Bob (找规律+二进制)
- 山东省第四届ACM大学生程序设计竞赛-Alice and Bob(二进制&&找规律)
- 第7届山东省赛sdut 3566---Triple Nim
- 第四届 山东省ACM A-Number and B-Number(数位DP+二分 待整理)
- 第四届 山东省ACM Boring Counting(划分树+二分 主席树待整理)
- 山东省第二届 ACM 省赛 Simple Game (Nim+Bash)
- 山东省第七届ACM大学生程序设计竞赛 训练总结 [8/12] 待补
- 山东省第三届ACM大学生程序设计竞赛(待添加)
- 山东省第八届 ACM 省赛 Parity check (规律、水)
- 产生长度为10以内整数的随机字符串(java)
- PHP magic_quotes_gpc的使用方法详解
- 最实用css3常用知识点梳理一:选择器+计数器
- Redis 有序集合
- hdu 1285确定比赛名次 (拓扑排序)
- 第七届 山东省ACM Triple Nim(找规律 待整理)
- Java设计模式学习01——单例模式
- Linux进程同步与通讯:共享内存和信号量的使用
- Java集合框架总结
- java中的继承和多态
- 如果使用ssm框架搭建应用,静态资源找不到
- 安卓自定义View实现文字环绕图片
- 网页由标签组成
- C++_class Template about Stack(使用类模板实现栈操作)