HUST 1372 marshmallow
很简单的博弈题.....算几组能得到规律了。
某个状态先手要赢 等价于 之前有一种状态是后手赢,先手可以保证让现在这个状态到达那个状态
#include<cstdio>
#include<cstring>
#include<ctime>
#include<algorithm>
using namespace std; const int maxn = + ;
int a[maxn], b[maxn];
int n, m; int gcd(int a, int b)
{
int t;
while (b)
{
t = a%b;
a = b;
b = t;
}
return a;
} void init()
{
for (int i = ; i <= ; i++) a[i] = i, b[i] = i;
for (int i = ; i <= ; i = i + )
{
swap(b[i - ], b[i - ]);
}
b[] = ; } int main()
{
init();
while (~scanf("%d%d", &n, &m)){
int tot = ;
for (int i = ; i <= ; i++)
if (a[i] <= n&&b[i] <= m) tot++; int fz, fm;
fz = tot;
fm = m*n;
if (tot == ) fz = , fm = ;
else
{
int a=fz / gcd(fz, fm),b = fm / gcd(fz, fm);
fz = a; fm = b;
}
printf("%d/%d\n", fz, fm);
}
return ;
}
HUST 1372 marshmallow的更多相关文章
- mysql 错误 ERROR 1372 (HY000): Password hash should be a 41-digit hexadecimal number 解决办法
MySQL创建用户(包括密码)时,会提示ERROR 1372 (HY000): Password hash should be a 41-digit hexadecimal number: 问题原因: ...
- Android 6编译环境搭建 (Marshmallow)
1.安装 ubuntu 14.03 尽管android推荐 ubuntu 15, 安全起见,还是装LTS的14.04,步骤跳过 2. JDK: Marshmallow 需要 JDK8 ,添个源,顺手配 ...
- HUST 1017 - Exact cover (Dancing Links 模板题)
1017 - Exact cover 时间限制:15秒 内存限制:128兆 自定评测 5584 次提交 2975 次通过 题目描述 There is an N*M matrix with only 0 ...
- hiho #1372:平方求 (bfs)
#1372 : 平方求和 时间限制:1000ms 单点时限:1000ms 内存限制:256MB 描述 对于一个非负整数n,最少需要几个完全平方数,使其和为n? 输入 输入包含多组数据.对于每组数据: ...
- ubuntu 16.04 source (HUST and 163)
#HUST deb http://mirrors.hust.edu.cn/ubuntu/ xenial main restricted universe multiverse deb http://m ...
- Dancing Link --- 模板题 HUST 1017 - Exact cover
1017 - Exact cover Problem's Link: http://acm.hust.edu.cn/problem/show/1017 Mean: 给定一个由0-1组成的矩阵,是否 ...
- hust 1010 最短循环节点
题目链接:http://acm.hust.edu.cn/problem/show/1010 KMP失配指针的利用: next数组前缀和后缀最长公共长度,这样len - next[len];就是最短的循 ...
- Android 6 Marshmallow USB调试授权
Google在Android在5.1版之后进行了重大变革,推出了Android 6 Marshmallow,我们先看看当它接上工作站时,有什么样的状况出现. 如图1所示,会弹出一个窗口,[是否允许此计 ...
- android开发者博客二月-Marshmallow and User Data
又是一篇翻译,这篇快了很多,不过也花了快一个小时,可能熟悉一点.关于6.0权限的,让你做用户认为正确的事情. Marshmallow and UserData 2016,2,1 棉花糖和用户数据 由J ...
随机推荐
- UVa11235 RMQ
input 1<=n,q<=100000 升序序列a1 a2 a3 ... an -100000<=ai<=100000 q行i j 1<=i,j<=n 输入结束标 ...
- android 市场发布应用小结
1:360平台发布应用 网址:http://dev.app.360.cn/ 2:腾讯应用宝 平台发布应用: 地址:http://op.open.qq.com/ (未审核通过的不能更新版本) 3:发布 ...
- sphinx分域搜索
http://stackoverflow.com/questions/2526407/complex-query-with-sphinx 比如要实现和如下sql代码相同的功能: SELECT * FR ...
- SQL清除所有数据库日志脚本
--SQL清除所有数据库日志脚本 declare @CurrentDataBaseName nvarchar(100) declare @CurrentDataBaseID nvarchar(100) ...
- 常用的dos命名
注销:logoff 注册表:regedit 查看显存:dxdiag 删除文件: del +文件 删除文件夹: rd+(/s)+文件名 (/s表示删除文件下的子目录和文件); 系统配置实用程序: msc ...
- 【矩阵压缩】 poj 1050
题意:给一个矩阵,里面有正负数,求子矩阵和的最大值 #include <iostream> #include <cstdio> #include <stdlib.h> ...
- 用FusionChartsFree做饼状图、柱状图、折线图的实例
1.先来看看要进行表现的页面:myChart.jsp <%@ page language="java" contentType="text/html; charse ...
- 转:web_url函数学习
web_url语法: Int Web_url(const char *name, const char * url, <Lists of Attributes>, [EXTR ...
- HDU 5512 Pagodas
2015 ACM / ICPC 沈阳现场赛 D 题 找了一小时规律......发现是个GCD. #include<cstdio> #include<cstring> #incl ...
- VHD容量调整的方法(保存原有vhd)
VHD容量调整的方法(保存原有vhd)特别对于RAMOS的VHD,调整VHD容量的办法:1.在WIN7或者7PE中,右击我的电脑→管理→磁盘管理,挂载原始VHD文件,然后新建一个VHD文件,初始化,格 ...