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: ...
随机推荐
- ZOJ 3203 Light Bulb - 求导求最大值
如果L全在地面上: 输出 h * D / H 如果L全在墙上: 输出 h 否则: (D - X ) / X = Y / (H - h) L = D - X + h - Y 然后对L求导即可 #incl ...
- 面向对象程序设计-C++ Steam & Vector 【第三次上课笔记】
大家可以下载后用Vim 或者 Sublime Text等文本编辑器查看 Conference: http://blog.csdn.net/candy1232009/article/details/70 ...
- (Problem 5)Smallest multiple
2520 is the smallest number that can be divided by each of the numbers from 1 to 10 without any rema ...
- dotnet tools 运行 dotnet run
dotnet tools 运行 dotnet run dotnet run 命令介绍 前言 本篇主要介绍 asp.net core 中,使用 dotnet tools 运行 dotnet run 之后 ...
- 使用zxing生成二维码 - servlet形式
因为项目有个功能需要打印二维码,因为我比较喜欢使用html+css+js实现,所以首先想到的是jquery.qrcode.js插件,这个插件可以用canvas和table生成二维码,效果也不错,不过对 ...
- pop,墨刀,快现、justinmind 、Axure
原型设计软件 墨刀:https://modao.cc Justinmind: http://www.zhihu.com/question/26662368/answer/33586218 http:/ ...
- C++ 中mallon动态分配内存大小用法
#include<iostream> using namespace std; int main(){ char *s; int n; cin>>n; s= (char *) ...
- SAX方式解析XML
sax解析分为以下几步: 1 获取一个saxparserfactory 2 获取一个解析器 3 创建handler对象,这个myHandler是继承了DefaultHandler的一个类,这个实现类里 ...
- IOS_Note
关键字:可以搜索这些关键字找到具体内容 退回输入键盘.CGRect.CGPoint & CGSize.设置透明度.设置背景色.自定义颜色. 竖屏.横屏.状态栏高 (显示时间和网络状态). 导 ...
- Java__jar包的简单操作
工作需要研究了下jar,这里就举个简单的例子,以helloworld为例吧 1.启动eclipse编写代码: 次步不做赘述 package cn.test.jar; public class Hell ...