HDU 4839 The Game of Coins _(:зゝ∠)_
来源:互联网 发布:java split函数 编辑:程序博客网 时间:2024/06/03 17:14
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 __int64inline 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;}
0 0
- HDU 4839 The Game of Coins _(:зゝ∠)_
- HDU 4915 Parenthese sequence _(:зゝ∠)_ 呵呵
- _(:зゝ∠)_
- #HDU1667#The Rotation Game (IDA*_搜索)
- UVALive 6663 Count the Regions 离散+bfs染色_(:зゝ∠)_
- hdu 4155 The Game of 31
- HDU 4876 ZCC loves cards _(:зゝ∠)_ 随机输出保平安
- HDU 4937 Lucky Number 规律题_(:зゝ∠)_
- HDU 4941 Magical Forest _(:зゝ∠)_ 模拟题
- 2014百度之星复赛解题报告:The Game of Coins
- NOIP2016提高组酱油记_(:зゝ∠)_
- 【记忆化搜索】 HDU-4155-The Game of 31
- HDU 4155 The Game of 31 (博弈)
- The rule of game
- Game of the Rows
- Game of the Rows
- hdu Beauty of Sequence (好题_集合问题)
- Game of Connections HDU
- java在指定路径下查找所有文件及其子文件名中,是否包含指定查询的关键字
- 加密与解密_Playfair密码变种加密方法-解题思路及过程
- 邮件正文及其附件的发送的C++实现
- hid keyboard device异常,电脑键盘驱动出现问题,无法输入,利用虚拟键盘解决问题
- DateTime之时间比较(Compare 方法)
- HDU 4839 The Game of Coins _(:зゝ∠)_
- Scheme 的 xml文件读写
- "",IDC_FRAME,"Static",SS_BLACKFRAME,226,8,20,20 CONTROL IDB_BACK,IDC_BACK,"Static",SS_
- HDOJ 1874 畅通工程续——结构体模拟邻接链表的SPFA算法
- poj 1947 Rebuilding Roads(树形dp)
- [Matlab][数据挖掘算法][线性回归]
- Linux下安装MySQL数据库以及用C语言编程存取数据库
- leetcode - Remove Duplicates from Sorted List
- 访问权限控制