problem:http://acm.hdu.edu.cn/showproblem.php?pid=4329

题意:模拟  a.

          p(r)=   R'/i   rel(r)=(1||0)  R是前n次输入有关URL的个数  R'是后n次已经输入有关URL的个数

  b.

      

另加:输入 istringstream

#include<iostream>
#include<sstream> //istringstream 必须包含这个头文件
#include<string>
using namespace std;
int main()
{
string str="i an a boy";
istringstream is(str);
string s;
while(is>>s)
{
cout<<s<<endl;
} }

#include<iostream>
#include<sstream>
#include<cstring>
#include<cstdio>
#include<map>
#include<algorithm>
using namespace std;
char a[];
int r[];
map<string,int>mp[];
void init(int k)
{
istringstream str(a);
string tmp;
str>>tmp;
mp[k].clear();
while(str>>tmp)
{
r[k]++;
mp[k][tmp]=;
}
}
double get_avep(int k)
{
istringstream str(a);
string tmp;
str>>tmp;
int i=,R=;
double ansn=0.0;
while(str>>tmp)
{
i++;
if(mp[k][tmp]==)
{
R++;
ansn+=(R*1.0)/i;
}
}
ansn/=r[k]*1.0;
return ansn;
}
int main()
{
int t;
cin>>t;
while(t--)
{ memset(r,,sizeof(r));
int n,kcas=; cin>>n;
getchar(); for(int i=;i<=n;++i)
{
gets(a);
init(i);
}
double ans=0.0;
for(int i=;i<=n;++i)
{
gets(a); ans+=get_avep(i);
}
ans/=n;
cout<<"Case #"<<++kcas<<": ";
printf("%.6lf\n",ans);
}
return ;
}

hdu 4329的更多相关文章

  1. HDU 4329 MAP(stringstream的用法)

    这个题目有点绕,但是按着他的意思写不难模拟出来.本来是一场学弟们的训练赛,我这个学长在赛场上却WA了四次都没过,三条黑线就一直在我的脑袋上挂着... 赛后开始找原因,后来发现题目看错了,1/R中的R是 ...

  2. HDU 4329 Contest 3

    果然换个编译器就过了.总的来说,不难,不过就是处理一些空格.学习了一个新的类 istringstream可以按空格划分.然后,那条式子要理解. 式子的意义是: 找到一个串,该串在query中是第几个找 ...

  3. HDOJ 2111. Saving HDU 贪心 结构体排序

    Saving HDU Time Limit: 3000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total ...

  4. 【HDU 3037】Saving Beans Lucas定理模板

    http://acm.hdu.edu.cn/showproblem.php?pid=3037 Lucas定理模板. 现在才写,noip滚粗前兆QAQ #include<cstdio> #i ...

  5. hdu 4859 海岸线 Bestcoder Round 1

    http://acm.hdu.edu.cn/showproblem.php?pid=4859 题目大意: 在一个矩形周围都是海,这个矩形中有陆地,深海和浅海.浅海是可以填成陆地的. 求最多有多少条方格 ...

  6. HDU 4569 Special equations(取模)

    Special equations Time Limit:1000MS     Memory Limit:32768KB     64bit IO Format:%I64d & %I64u S ...

  7. HDU 4006The kth great number(K大数 +小顶堆)

    The kth great number Time Limit:1000MS     Memory Limit:65768KB     64bit IO Format:%I64d & %I64 ...

  8. HDU 1796How many integers can you find(容斥原理)

    How many integers can you find Time Limit:5000MS     Memory Limit:32768KB     64bit IO Format:%I64d ...

  9. hdu 4481 Time travel(高斯求期望)(转)

    (转)http://blog.csdn.net/u013081425/article/details/39240021 http://acm.hdu.edu.cn/showproblem.php?pi ...

随机推荐

  1. hadoopfs: 未找到命令...

    https://zhidao.baidu.com/question/240817305095236244.html 学习hadoop测试http://blog.csdn.net/thinkpadshi ...

  2. (原创)使用VMware安装Ubuntu,怎么无法使用startx进入桌面模式?

    最近在VMware中安装Ubuntu时,发现VMware的快速安装后是文本模式,无法使用startx进入桌面模式,非常不方便.此问题为默认安装方式,需要设置安装方式. 操作系统:Windows 8.1 ...

  3. [LeetCode] Bulb Switcher 灯泡开关

    There are n bulbs that are initially off. You first turn on all the bulbs. Then, you turn off every ...

  4. 延迟加载外部js文件,延迟加载图片(jquery.lazyload.js和echo,js)

    js里一说到延迟加载,大都离不开两种情形,即外部Js文件的延迟加载,以及网页图片的延迟加载: 1.首先简单说一下js文件的3种延迟加载方式: (1)<script type="text ...

  5. blog (后续更新)

    设计Model(设计数据库) from django.db import models # Create your models here. class BlogsPost(models.Model) ...

  6. Fiddler抓包工具使用基础

    官网下载Fiddler Fiddler的官方网站:  www.fiddler2.com Fiddler是最强大最好用的Web调试工具之一,它能记录所有客户端和服务器的http和https请求,允许你监 ...

  7. 罗马数字转整数Leetcode13

    该题较为简单,但是需要知道罗马数字的表示以及取值.用了一下map,其实之前没用过,但仔细看了一下跟python的字典实际上差不多,扫了一遍函数就直接可以用了. class Solution { pub ...

  8. 两种遍历list

    li=[[1,2,3,4,5],[1,2,3,4,5],[1,2,3,4,5],[1,2,3,4,5],[1,2,3,4,5]]s=0for i in range(0,5): for j in ran ...

  9. ios小数向上、下取整,计算结果向上、下取整

    [摘要:小数背上与整,指小数局部间接进1 x=3.14, ceilf (x)=4 小数背下与整,指间接往失落小数局部 x=3.14,floor(x)=3 盘算效果背上与整 A被除数,B除数 ,(AB- ...

  10. Python json.dumps 特殊数据类型的自定义序列化操作

    场景描述: Python标准库中的json模块,集成了将数据序列化处理的功能:在使用json.dumps()方法序列化数据时候,如果目标数据中存在datetime数据类型,执行操作时, 会抛出异常:T ...