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. 理解HTML语义化

    1.什么是HTML语义化? <基本上都是围绕着几个主要的标签,像标题(H1~H6).列表(li).强调(strong em)等等> 根据内容的结构化(内容语义化),选择合适的标签(代码语义 ...

  2. [LeetCode] Is Subsequence 是子序列

    Given a string s and a string t, check if s is subsequence of t. You may assume that there is only l ...

  3. [LeetCode] Ransom Note 赎金条

    
Given
 an 
arbitrary
 ransom
 note
 string 
and 
another 
string 
containing 
letters from
 all 
th ...

  4. .NET跨平台之旅:将示例站点升级至ASP.NET Core 1.0

    北京时间6月28日凌晨,微软发布了 .NET Core 1.0,详见新闻 .NET Core 1.0 正式发布了 ,ASP.NET Core 1.0 也随之一起发布了. 紧跟这次发布,我们将跑在 Li ...

  5. 【WPF】新复制wpf项目报错

    错误提示:Program does not contain a static 'Main' method suitable for an entry point 1.App.xaml 文件属性:生成操 ...

  6. Cookie的应用

    作用:在浏览器当中用cookie来保存参数,比如实现登录功能时用来保存账号 <%@ page language="java" import="java.util.* ...

  7. [筆記] Ubuntu Linux 使用 apt-get 指令移除軟體並清理遺留的垃圾

    This is come from    http://blog.lyhdev.com/2013/01/ubuntu-linux-apt-get.html 在 Ubuntu 下移除某個軟體套件,使用的 ...

  8. [原创开源项目]EPUBBuilder一款在线的epub电子书编辑工具

    epub 感觉自己么么哒, epub书:国外最流行的电子书格式: epub电子书介绍: epub全称为Electronic Publication的缩写,意为:电子出版, epub于2007年9月成为 ...

  9. 动态生成二维码插件 jquery.qrcode.js

    前段时间做项目,需要动态生成一个二维码,于是就在网上找了一下发现一个jquery插件jquery.qrcode.js,所以今天就简单说一下这个插件的使用: jquery.qrcode.js是依赖jqu ...

  10. 常用js归纳

    一.获取地址栏参数 /*根据name获取URL参数*/ function getQueryString(name) { var reg = new RegExp("(^|&)&quo ...