HDU 4329 Contest 3
果然换个编译器就过了。总的来说,不难,不过就是处理一些空格。学习了一个新的类 istringstream可以按空格划分。然后,那条式子要理解。
式子的意义是:
找到一个串,该串在query中是第几个找到/它的实际位置。之和再除以给出的有几个串就是AVEP
#include <iostream>
#include <cstdio>
#include <sstream>
#include <map>
#include <string>
#include <algorithm> using namespace std;
string str[105];
string sstr[105]; int main(){
int T,kase=0,n,t1,t2; double ans,par;
scanf("%d",&T);
while(T--){
scanf("%d",&n);
getchar();
for(int i=1;i<=n;i++)
getline(cin,str[i]);
for(int i=1;i<=n;i++)
getline(cin,sstr[i]);
ans=0;
for(int i=1;i<=n;i++){
par=0;
map<string,int>M;
stringstream sin(str[i]);
string c;
t1=t2=0;
sin>>c;
while(sin>>c){
M[c]=1;
t1++;
}
if(t1==0) continue;
stringstream csin(sstr[i]);
csin>>c;
int j=0;
while(csin>>c){
t2++;
if(M.find(c)!=M.end()){
j++;
par+=(double)j/t2;
}
}
ans+=(par/t1);
}
printf("Case #%d: %.6lf\n",++kase,ans/n);
}
}
HDU 4329 Contest 3的更多相关文章
- hdu 4329
problem:http://acm.hdu.edu.cn/showproblem.php?pid=4329 题意:模拟 a. p(r)= R'/i rel(r)=(1||0) R ...
- HDU 5045 Contest(状压DP)
Problem Description In the ACM International Collegiate Programming Contest, each team consist of th ...
- hdu - 5045 - Contest(国家压缩dp)
意甲冠军:N个人M通过主打歌有自己的期望,每个问题发送人玩.它不能超过随机播放的次数1,追求最大业绩预期 (1 ≤ N ≤ 10,1 ≤ M ≤ 1000). 主题链接:pid=5045" ...
- [ACM] hdu 5045 Contest (减少国家Dp)
Contest Problem Description In the ACM International Collegiate Programming Contest, each team consi ...
- HDU–5988-Coding Contest(最小费用最大流变形)
Coding Contest Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others)To ...
- hdu 5045 Contest(状态压缩DP)
题解:我们使用一个二位数组dp[i][j]记录进行到第i个任务时,人组合为j时的最大和(这里的j我们用二进制的每位相应一个人). 详细见代码: #include <iostream> #i ...
- HDU 5045 Contest
pid=5045">主题链接~~> 做题感悟:比赛时这题后来才写的,有点小尴尬.两个人商议着写写了非常久才写出来,I want to Powerful ,I believe me ...
- HDU 4329 MAP(stringstream的用法)
这个题目有点绕,但是按着他的意思写不难模拟出来.本来是一场学弟们的训练赛,我这个学长在赛场上却WA了四次都没过,三条黑线就一直在我的脑袋上挂着... 赛后开始找原因,后来发现题目看错了,1/R中的R是 ...
- HDU 4335 Contest 4
利用降幂公式..呃,还是自己去搜题解吧.知道降幂公式后,就不难了. #include <iostream> #include <cstdio> #include <alg ...
随机推荐
- redis代码解析-dictionary类型
dict本质上是为了解决算法中的查找问题(Searching),一般查找问题的解法分为两个大类:一个是基于各种平衡树,一个是基于哈希表. redis中的dict传统的哈希算法类似,它采用某个哈希函数从 ...
- 【云快讯】之四十八《IBM和Cisco最新收购,加强Openstack易用能力》
2015-06-08 张晓东 东方云洞察 点击上面的链接文字,能够高速关注"东方云洞察"公众号 本周宣布的两起收购引人注意.思科购买Piston云计算公司.同期IBM的收购Blue ...
- ORACLE RAC 11G 添加以及删除UNDO表空间
在生产环境上,由于闪存盘的容量有限,现在需要将闪存盘里面的UNDO表空间,替换到非闪存的磁盘里面. 磁盘的使用情况如下: 表空间使用情况如下: RAC两个节点占用将近167G的空间. 操作步骤如下: ...
- BZOJ 3624 并查集 (Kruskal)
思路: 先把所有能加上的水泥路都加上 判断哪些是必加的鹅卵石路 再重新做一遍最小生成树 加上必加的鹅卵石路 一直加鹅卵石路 判一下是不是=k 最后加上水泥路就好了 //By SiriusRen #in ...
- python课程设计笔记(一)开发环境配置
今天开始学python,一个月后交成果?还是希望自己不要浮躁,认真地去学,有所付出也不期望太大回报. 现在还是一脸懵逼的状态,看着教程一点点来吧= = 毕竟我是最棒的最发光的阳光彩虹小白马! 1. 去 ...
- Linux常见后缀缩写含义
ctl: control rc: run control (A run-control file is a file of declarations or commands associated wi ...
- 去除input 在 webkit内核浏览器 选择历史时,有一个黄色背景
input:-webkit-autofill { -webkit-box-shadow: 0 0 0px 1000px white inset; } http://www.imooc.com/arti ...
- C语言-实现整数倒序输出
Action() { //实现一个3位数的倒序输出(123输出321) int n; int m=321; n=fun_mod(m,n); lr_output_message("%d&quo ...
- addEventListener()与removeEventListener(),追加事件和删除追加事件
addEventListener()与removeEventListener()用于追加事件和删除追加.所有的DOM节点中都包含这两种方法,并且它们都接受3个参数:要处理的事件名.作为事件处理程序的函 ...
- Hihocoder1350-Binary Watch
时间限制:10000ms单点时限:1000ms内存限制:256MB 描述 Consider a binary watch with 5 binary digits to display hours ( ...