51 Nod 1067 博弈 SG函数
1067 Bash游戏 V2
- 1 秒
- 131,072 KB
- 10 分
- 2 级题
输入
第1行:一个数T,表示后面用作输入测试的数的数量。(1 <= T <= 10000)
第2 - T + 1行:每行1个数N。(1 <= N <= 10^9)
输出
共T行,如果A获胜输出A,如果B获胜输出B。
输入样例
3
2
3
4
输出样例
B
A
A 1e9过大,打表找规律;
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstdlib>
#include<cstring>
#include<string>
#include<cmath>
#include<map>
#include<set>
#include<vector>
#include<queue>
#include<bitset>
#include<ctime>
#include<time.h>
#include<deque>
#include<stack>
#include<functional>
#include<sstream>
//#include<cctype>
//#pragma GCC optimize(2)
using namespace std;
#define maxn 200005
#define inf 0x7fffffff
//#define INF 1e18
#define rdint(x) scanf("%d",&x)
#define rdllt(x) scanf("%lld",&x)
#define rdult(x) scanf("%lu",&x)
#define rdlf(x) scanf("%lf",&x)
#define rdstr(x) scanf("%s",x)
#define mclr(x,a) memset((x),a,sizeof(x))
typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int U;
#define ms(x) memset((x),0,sizeof(x))
const long long int mod = 1e9 + 7;
#define Mod 1000000000
#define sq(x) (x)*(x)
#define eps 1e-5
typedef pair<int, int> pii;
#define pi acos(-1.0)
//const int N = 1005;
#define REP(i,n) for(int i=0;i<(n);i++)
typedef pair<int, int> pii; inline int rd() {
int x = 0;
char c = getchar();
bool f = false;
while (!isdigit(c)) {
if (c == '-') f = true;
c = getchar();
}
while (isdigit(c)) {
x = (x << 1) + (x << 3) + (c ^ 48);
c = getchar();
}
return f ? -x : x;
} ll gcd(ll a, ll b) {
return b == 0 ? a : gcd(b, a%b);
}
int sqr(int x) { return x * x; } /*ll ans;
ll exgcd(ll a, ll b, ll &x, ll &y) {
if (!b) {
x = 1; y = 0; return a;
}
ans = exgcd(b, a%b, x, y);
ll t = x; x = y; y = t - a / b * y;
return ans;
}
*/ int f[maxn];
int SG[maxn], S[maxn]; void sg(int n) {
// int i, j;
ms(SG);
for (int i = 1; i <= n; i++) {
ms(S);
for (int j = 1; f[j] <= i && j <= 3; j++) {
S[SG[i - f[j]]] = 1;
}
for (int j = 0;; j++)if (!S[j]) {
SG[i] = j; break;
}
}
} int main()
{
// ios::sync_with_stdio(0);
f[1] = 1; f[2] = 3; f[3] = 4;
/* sg(100); int ans = 0;
for (int i = 1; i <= 100; i++) {
cout << i << ' '; ans = SG[i];
if (ans)cout << "A" << endl;
else cout << "B" << endl;
}
*/
int T = rd();
while (T--) {
int n = rd();
if (n % 7 == 0 || ((n - 2) % 7 == 0)) {
puts("B");
}
else puts("A");
}
return 0;
}
51 Nod 1067 博弈 SG函数的更多相关文章
- S-Nim HDU 1536 博弈 sg函数
S-Nim HDU 1536 博弈 sg函数 题意 首先输入K,表示一个集合的大小,之后输入集合,表示对于这对石子只能去这个集合中的元素的个数,之后输入 一个m表示接下来对于这个集合要进行m次询问,之 ...
- hdu 3032(博弈sg函数)
题意:与原来基本的尼姆博弈不同的是,可以将一堆石子分成两堆石子也算一步操作,其它的都是一样的. 分析:由于石子的堆数和每一堆石子的数量都很大,所以肯定不能用搜索去求sg函数,现在我们只能通过找规律的办 ...
- HDU-4678 Mine 博弈SG函数
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4678 题意就不说了,太长了... 这个应该算简单博弈吧.先求联通分量,把空白区域边上的数字个数全部求出 ...
- (转)博弈 SG函数
此文为以下博客做的摘要: https://blog.csdn.net/strangedbly/article/details/51137432 ---------------------------- ...
- 尼姆博弈+SG函数
博弈这个东西真的很费脑诶.. 尼姆博奕(Nim Game):游戏者轮流从一堆棋子(或者任何道具)中取走一个或者多个,最后不能再取的就是输家.当指定相应数量时,一堆这样的棋子称作一个尼姆堆 当n堆棋子的 ...
- 【转】博弈—SG函数
转自:http://chensmiles.blog.163.com/blog/static/12146399120104644141326/ http://blog.csdn.net/xiaofeng ...
- HDU 1848 Fibonacci again and again (斐波那契博弈SG函数)
Fibonacci again and again Time Limit: 1000MS Memory Limit: 32768KB 64bit IO Format: %I64d & ...
- Light OJ 1199 - Partitioning Game (博弈sg函数)
D - Partitioning Game Time Limit:4000MS Memory Limit:32768KB 64bit IO Format:%lld & %llu ...
- LightOJ 1315 - Game of Hyper Knights(博弈sg函数)
G - Game of Hyper Knights Time Limit:1000MS Memory Limit:32768KB 64bit IO Format:%lld & ...
随机推荐
- 手动编译cloudfoundry
1.下载cloudfoundry源代码 git clone 2.BOSH的官方定义 BOSH是一个针对大规模分布式系统的部署和生命周期管理的开源工具,其基础是"a tool of relea ...
- C#HTML解析利器HtmlAgilityPack
HtmlAgilityPack是一个开源的解析HTML元素的类库,最大的特点是可以通过XPath来解析HMTL,如果您以前用C#操作过XML,那么使用起HtmlAgilityPack也会得心应手.目前 ...
- not1,not2,bind1st和bind2nd详解
1.引言 bind1st和bind2nd函数用于将一个二元函数对象(binary functor,bf)转换成一元函数对象(unary functor,uf).为了达到这个目的,它们需要两个参数:要转 ...
- jquery函数$.proxy简单示例
来自于<jquery 权威指南> ------------------------------ <!DOCTYPE html PUBLIC "-//W3C//DTD XHT ...
- revert
git revert是用一次新的commit来回滚之前的commit
- mybatis思维导图(一)
写在前面 与hibernate相比,我无疑更喜欢mybatis,就因为我觉得它真的好用,哈哈.它简单上手和掌握:sql语句和代码分开,方便统一管理和优化:当然缺点也有:sql工作量很大,尤其是字段多. ...
- 并发编程CAS操作
并发编程CAS操作 简介 CAS即compare and swap,中文就是比较并交换 CAS是Java并发包的基石 原理 其实CAS的原理相对来说比较简单.将要被改变的数据和期望的值作比较,当两个值 ...
- auth复习和BBS项目的登录(1)
auth复习 auth组件 验证:authenticate(request,username='andy',password='123) 登录:login(request,user) 注销:login ...
- javascript总结27 :特殊引用类型String/Number/Boolean
为了方便操作基本数据类型,JavaScript还提供了三个特殊的引用类型:String/Number/Boolean 1 Number 例如: var s1 = "zhangsan&quo ...
- javascript总结23:javascript 数据类型与变量
1 基本类型和引用类型 JavaScript中的数据类型分为两类:基本类型和引用类型 基本类型:直接存储值,画图解释 Number.String.Boolean Undefined.Null 引用类 ...