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 ...
随机推荐
- 第二篇:SpringBoot配置详解
SpringBoot 是为了简化 Spring 应用的创建.运行.调试.部署等一系列问题而诞生的产物,自动装配的特性让我们可以更好的关注业务本身而不是外部的XML配置,我们只需遵循规范,引入相关的依赖 ...
- 文件上传前端操作-增加文件与删除文件按钮(jquery实现)
初始 删除与添加 <!DOCTYPE html> <html> <head> <title></title> <meta charse ...
- Android数据库高手秘籍:SQLite命令
要想熟练地操作任何一个数据库,最最基本的要求就是要懂SQL语言,这也是每个程序员都应该掌握的技能.虽说SQL博大精深,要想精通确实很难,但最基本的一些建表命令,增删改查,大家还是必须要学会的. SQL ...
- [CortexM0--stm32f0308]Low Power Mode
问题描写叙述 stm32f0308正常是运行在Run mode下.这样的mode是在reset之后的默认模式.Low Power Mode.即低功耗模式.用于在IC空暇时能够考虑选择进入.使系统耗能减 ...
- “XXX.Index”不扩展类“System.Web.UI.Page”,因此此处不同意的问题
"XXX.Index"不扩展类"System.Web.UI.Page",因此此处不同意的问题 原因:设计页面继承的路径和后台.cs页面类的路径不一致造成的 看下 ...
- codecombat之KithGard地牢19-37关代码分享
codecombat中国游戏网址:http://www.codecombat.cn/ 全部代码为javascript代码分享 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 19 ...
- linux:共享内存
#include <sys/ipc.h> #include <sys/shm.h> #include <string.h> #include <stdio.h ...
- PHP7添加swoole扩展
swoole需要php版本在7.0以上. 1.进入php目录中的bin目录下,通过pecl指令进行安装. cd /usr/local/php7/bin [root@localhost bin]# pw ...
- UESTC--1263--The Desire of Asuna(贪心)
The Desire of Asuna Time Limit: 1000MS Memory Limit: 65535KB 64bit IO Format: %lld & %llu Su ...
- 院校-美国:美国国立卫生研究院(NIH)
ylbtech-院校-美国:美国国立卫生研究院(NIH) 美国国立卫生研究院(简称NIH)位于美国马里兰州贝塞斯达(Bethesda),是美国最高水平的医学与行为学研究机构,初创于1887年,任务是探 ...