hdu 5229 ZCC loving string
来源:互联网 发布:php配置环境工具 编辑:程序博客网 时间:2024/05/08 09:44
#include <cstdio>#include <iostream>#include <algorithm>#include <queue>#include <stack>#include <cstdlib>#include <cmath>#include <set>#include <map>#include <vector>#include <cstring>#define INF 100000000using namespace std;long long int gcd(long long a,long long b){ return b == 0?a:gcd(b,a%b);}int main(){ int t; scanf("%d",&t); while(t--){ long long int n; cin >> n; map<string,int> a; int odd = 0; for(int i = 0;i < n;i++){ string b; cin >> b; odd += b.length()%2; if(a.find(b)!=a.end()){ a[b]++; } else{ a[b] = 1; } } long long int ans = 0; for(map<string,int>::iterator ite = a.begin();ite != a.end();ite++){ long long int t = ite->second; ans += t*(t-1)/2; } ans += odd*(n-odd);// cout << ans << endl; long long tmp = n * (n-1)/2; long long int gc = gcd(tmp,ans); cout << ans/gc << "/" << tmp/gc << endl;// printf("%d/%d\n",ans/gc,tmp/gc); } return 0;}
0 0
- hdu 5229 ZCC loving string
- HDU 5229 ZCC loves strings
- hdu 5229 ZCC loves strings
- hdu 5229 ZCC loves strings
- HDU 5229 ZCC loves strings
- HDU 5229 ZCC loves strings
- hdu 5229 ZCC loves strings(博弈)
- HDU 5229 - ZCC loves strings (思维)
- HDU-5229-ZCC loves strings 【奇偶】
- loving
- loving
- hdu 5229 ZCC loves strings && BestCoder Round #41 1002
- HDU 5229 - ZCC loves strings(博弈+概率)
- hdu 5229 ZCC loves strings(Bestcoder Round #41)
- Hdu 5229 ZCC loves strings(简单题)
- hdu 4882 ZCC Loves Codefires
- hdu 4882ZCC Loves Codefires
- HDU 4876 ZCC loves cards
- 清除浮动常用方法
- asp.net 学习之路之chart控件
- poj1151 Atlantis
- 一点点开始熟悉C++11的新特性
- CSS定位——position、float小结
- hdu 5229 ZCC loving string
- Spring+SpringMVC+Mybatis+Mysql整合实例
- Java异常处理
- C++自增操作符你真的懂?
- 第2章:文件I/O
- 基于VHDL的层次化设计:异步清零和同步使能4位十六进制加法计数器和七段显示译码器的元件例化实现
- LintCode-更新二进制位
- 用类创建二叉搜索树
- Windows Phone 10(Lumia 920)升级记录——2