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. JavaScript自动生成博文目录导航

    转载于:JavaScript自动生成博文目录导航 我们在写博客的时候,如果博文里面有目录,会给人结构清晰.一种一目了然的感觉,看目录就知道这篇博文要讲解的内容,并且点击目录标题就可以跳转到 具体的内容 ...

  2. 【codevs1106】 篝火晚会

    http://codevs.cn/problem/1106/ (题目链接) 题意 将1~n顺序排列的环改成另一个环,问n-不动点数. Solution 啊智障啦,不会做×_× 左转hzwer 代码 / ...

  3. [LeetCode] The Skyline Problem 天际线问题

    A city's skyline is the outer contour of the silhouette formed by all the buildings in that city whe ...

  4. [LeetCode] N-Queens II N皇后问题之二

    Follow up for N-Queens problem. Now, instead outputting board configurations, return the total numbe ...

  5. 使用SharpPCap在C#下进行网络抓包

    在做大学最后的毕业设计了,无线局域网络远程安全监控策略那么抓包是这个系统设计的基础以前一直都是知道用winpcap的,现在网上搜了一下,有用C#封装好了的,很好用下面是其中的几个用法这个类库作者的主页 ...

  6. neo4j初次使用学习简单操作-cypher语言使用

    Neo4j 使用cypher语言进行操作 Cypher语言是在学习Neo4j时用到数据库操作语言(DML),涵盖对图数据的增删改查  neo4j数据库简单除暴理解的概念: Neo4j中不存在表的概念, ...

  7. 【USACO 3.2】Sweet Butter(最短路)

    题意 一个联通图里给定若干个点,求他们到某点距离之和的最小值. 题解 枚举到的某点,然后优先队列优化的dijkstra求最短路,把给定的点到其的最短路加起来,更新最小值.复杂度是\(O(NElogE) ...

  8. [UWP] 使用SemanticZoom控件

    在写一个看新闻软件的时候,用到了SemanticZoom控件,遇到了一些问题,比如如何根据首字母分类,以及放大视图中有数据的和没数据的通过背景色或前景色区分,幸运的是,all solved. 先来个效 ...

  9. Python_猜大小

    # 需要在python3上执行 import random def game (capital = 1000): point1 = random.randrange(1,7) point2 = ran ...

  10. 图片懒加载jquery lazyload

    <script type="text/javascript" src="jquery-1.11.3.min.js"></script>& ...