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. [LeetCode] Generalized Abbreviation 通用简写

    Write a function to generate the generalized abbreviations of a word. Example: Given word = "wo ...

  2. Redis集群~windows下搭建Sentinel环境及它对主从模式的实际意义

    回到目录 关于redis-sentinel出现的原因 Redis集群的主从模式有个最大的弊端,就是当主master挂了之前,它的slave从服务器无法提升为主,而在redis-sentinel出现之后 ...

  3. 网站收集ing....

    1.账号注册网址 http://bugmenot.com/ PS:只要输入相关网站域名就能立即完成网站注册 2.博客网站 CSDN,博客园,开源中国 3.破解网站 吾爱破解 4.矢量图标 http:/ ...

  4. Equal Sides Of An Array

    参考:http://stackoverflow.com/questions/34584416/nested-loops-with-arrays You are going to be given an ...

  5. poj3417 LCA + 树形dp

    Network Time Limit: 2000MS   Memory Limit: 65536K Total Submissions: 4478   Accepted: 1292 Descripti ...

  6. Angular select 绑定复杂类型 设置默认项

    <select ng-model="selectedTask" ng-options="s.name for s in TaskList">< ...

  7. BFC的布局规则以及触发条件

          1   .BFC的含义 :          Block Formatting Contexts(BFC)                                      块级元 ...

  8. Linux创建WiFi热点

    手机流量用完,需要开WiFi,由于是LinuxMint,感觉配置还算容易,找到一个不错的教程,收藏一下,以备后用.除了修改配置文件那步在我的电脑不需要外其他基本正确,而且Mint本来就衍生自Ubunt ...

  9. win7搭建双系统ubuntu

    参考链接:http://www.linuxidc.com/Linux/2014-10/108430.htm 0.下载EasyBCD软件和ubuntu镜像1.在win7,右键我的电脑,磁盘管理,压缩卷, ...

  10. iframe自适应高度

    http://wenrunchang123.iteye.com/blog/1684843