题目链接:https://www.patest.cn/contests/gplt/L2-005

这个题理解是个大问题啊,“给定两个整数集合,它们的相似度定义为:Nc/Nt*100%。其中Nc是两个集合都有的不相等整数的个数,Nt是两个集合一共有的不相等整数的个数。你的任务就是计算任意一对给定集合的相似度。”  理解了很久,用set来去重。

 #include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <set>
using namespace std;
const int maxn = ;
set<int> gather[maxn];
int main()
{
int n = ,m = ;
scanf("%d",&n);
for(int i=;i<=n;i++)
{
scanf("%d",&m);
for(int j=;j<m;j++)
{
int x;
scanf("%d",&x);
gather[i].insert(x);
}
}
int k = ;
scanf("%d",&k);
int l = ,r = ;
while(k--)
{
scanf("%d %d",&l,&r);
int Count = ;
set<int>::iterator it;
for(it=gather[l].begin();it!=gather[l].end();it++)
{
if(gather[r].count(*(it)))
{
Count++;
}
// printf("%d\n",*it);
}
printf("%.2f%%\n",(double)Count/(double)(gather[l].size()+gather[r].size()-Count)*100.0);
}
return ;
}

最新文章

  1. 关于.NET异常处理的思考
  2. 业务中是否有必要让所有的ViewController统一继承抽象类
  3. .net 附加W3wp进程
  4. MessageDigest消息摘要
  5. Spark小课堂Week1 Hello Spark
  6. Android 主题动态切换框架:Prism
  7. iOS Crash文件的解析
  8. 企业生产环境中linux系统分区的几种方案
  9. 完整导出IntelliJ IDEA的快捷键
  10. AIX误删除LV后如何进行现场保护和数据恢复工作
  11. org.springframework.data.redis.serializer.SerializationException: Cannot serialize;
  12. TestNG entryset的用法及遍历map的用法
  13. 取消layUI中日期选择控件默认填充日期
  14. TCP 服务端接收数据解析工具类
  15. FFT ip core
  16. Android-Java-类与对象的关系
  17. C# 实现简单仿QQ登陆注册功能
  18. [CF1060E]Sergey and Subway[树dp]
  19. 程序中try、throw、catch三者之间的关系
  20. 2、Python特征

热门文章

  1. 01创建线程CreateThread和_beginthreadex
  2. 记一次header跨域与cookie共享
  3. [译]The Python Tutorial#6. Modules
  4. STM32CUBEMX入门学习笔记2:关于STM32芯片使用内部flash
  5. Linux交换分区swap
  6. 【15】ES6 for Humans: The Latest Standard of JavaScript: ES2015 and Beyond
  7. day04_03 题目判断三个数字中的最大值
  8. 【Istio】error initializing configuration &#39;/etc/istio/proxy/envoy-rev0.json&#39;: malformed IP address: istio-statsd-prom-bridge
  9. js多少时间之前
  10. Bash Command 1: find