HDU 4839 The Game of Coins _(:зゝ∠)_
mark:
#include"cstdio"
#include"iostream"
#include"queue"
#include"algorithm"
#include"set"
#include"queue"
#include"cmath"
#include"string.h"
#include"vector"
using namespace std; #define ll __int64
inline ll abs(ll x){return x>0?x:-x;}
ll gcd(ll a,ll b){if(a>b)swap(a,b); while(a){ b%=a;swap(a,b); }return b;} int main() {
ll T, i, j;scanf("%I64d", &T);
for(ll t = 1; t <= T; t++){
char a[1005], b[1005];
scanf("%s %s", a, b);
printf("Case #%I64d:\n", t);
ll len = strlen(a);
ll ga = 0, fa = 0, gb = 0, fb = 0;
for (i = 1; i<=len; i++)
{
if (strncmp(a, a+len-i, i) == 0) ga |= (ll)1 << i;
if (strncmp(a, b+len-i, i) == 0) fa |= (ll)1 << i;
if (strncmp(b, a+len-i, i) == 0) gb |= (ll)1 << i;
if (strncmp(b, b+len-i, i) == 0) fb |= (ll)1 << i;
}
ll dou1 = abs(ga - gb);
ll dou2 = abs(fb - fa); if (dou1 == dou2) { puts("1/2"); continue; }
if (dou1 == 0) { puts("1"); continue; }
if (dou2 == 0) { puts("0"); continue; }
ll GCD = gcd(dou1, dou2);
dou1 /= GCD; dou2 /= GCD;
printf("%I64d/%I64d\n", dou2, dou1+dou2);
}
return 0;
}
HDU 4839 The Game of Coins _(:зゝ∠)_的更多相关文章
- HDU 4937 Lucky Number 规律题_(:зゝ∠)_
把全部合法的进制打出来会发现合法的进制都是在 n/3 n/4 n/5的边上 然后暴力边上的进制数.. #include <cstdio> #include <set> type ...
- HDU 4876 ZCC loves cards _(:зゝ∠)_ 随机输出保平安
GG,,,g艹 #include <cstdio> #include <iostream> #include <algorithm> #include <st ...
- HDU 4915 Parenthese sequence _(:зゝ∠)_ 哈哈
哦,我没做 #include <cstdio> #include <cstring> #include <algorithm> const int N = 1000 ...
- UVALive 6663 Count the Regions 离散+bfs染色_(:зゝ∠)_
题目链接:option=com_onlinejudge&Itemid=8&page=show_problem&problem=4675">点击打开链接 gg.. ...
- Oracle学习总结_day03_day04_条件查询_排序_函数_子查询
本文为博主辛苦总结,希望自己以后返回来看的时候理解更深刻,也希望可以起到帮助初学者的作用. 转载请注明 出自 : luogg的博客园 谢谢配合! day03_条件查询_排序_函数 清空回收站: PUR ...
- C Primer Plus_第6章_循环_编程练习
1.题略 #include int main(void) { int i; char ch[26]; for (i = 97; i <= (97+25); i++) { ch[i-97] = i ...
- 转:HIBERNATE一些_方法_@注解_代码示例---写的非常好
HIBERNATE一些_方法_@注解_代码示例操作数据库7步骤 : 1 创建一个SessionFactory对象 2 创建Session对象 3 开启事务Transaction : hibernate ...
- 迅为4412开发板Linux驱动教程——总线_设备_驱动注册流程详解
本文转自:http://www.topeetboard.com 视频下载地址: 驱动注册:http://pan.baidu.com/s/1i34HcDB 设备注册:http://pan.baidu.c ...
- 3.IP地址分类_规划_子网掩码
IP地址分类_规划_子网掩码 3.1MAC地址 网卡的身份证号———MAC地址 MAC地址的长度为48位(6个字节),通常表示为12个16进制数,每2个16进制数之间用冒号隔开,如:08:00:20: ...
随机推荐
- 版本管理工具:linux下svn的基本使用
参考: linux下安装SVN http://jingyan.baidu.com/article/3c343ff7039de20d37796306.html svn客户端使用linux篇 ht ...
- ThinkPHP-3.2.3学习
一.下载安装 核心包:不用解释,最减版本 完整包:包括扩展功能(验证码.session等) 二.调试 ----www ---thinkphp_3 Application ...
- 面向对象程序设计-C++ Default constructor & Copy constructor& Destructor & Operator Overloading【第九次上课笔记】
先上笔记内容吧: 这次上课的内容有关 构造函数 析构函数 运算符重载 return * this 内容很细,大家好好回顾笔记再照应程序复习吧 :) #include <iostream> ...
- Ural 1086 - Cryptography
While preparing this problem set the jury has run into the following problem: it was necessary to se ...
- Week4(9月30日):
Part I:提问 =========================== 1.什么是DRY? 2.解释下面的模型验证规则. public class Movie { public int ID { ...
- vim常用操作技巧与配置
vi是linux与unix下的常用文本编辑器,其运行稳定,使用方便,本文将分两部分对其常用操作技巧和配置进行阐述,其中参考了网上的一些文章,对作者表示感谢 PART1 操作技巧 说明: 以下的例子中 ...
- QT实现图片按钮(用qss切割图片,或者放三张图片)
我在网上找了很久,把他综合了一下 不说了关键代码来了:(这是一张图片切图的效果) void SetButtonStyle(QPushButton *button, QString imgsrc, in ...
- Windows Phone 8初学者开发—第15部分:在选中ListItem时播放声音
原文 Windows Phone 8初学者开发—第15部分:在选中ListItem时播放声音 第15部分:在选中ListItem时播放声音 原文地址: http://channel9.msdn.co ...
- Python 2.7 学习笔记 访问mysql数据库
一.基本概念 使用python操作数据库,其基本的流程如下(其实所有开发语言访问数据库的流程都是这样). 1.第一,引入相应数据库的python数据库接口模块,针对不同的数据库类型,有不同的数据库访问 ...
- methanol 模块化的可定制的网页爬虫软件,主要的优点是速度快。
methanol模块化的可定制的网页爬虫软件,主要的优点是速度快. 下载:http://sourceforge.net/projects/methabot/?source=typ_redirect R ...