题意:

输入一个正整数N表示集合的个数(<=50),接着输入N行,每行包括一个数字x代表集合的容量(<=10000),接着输入x个非负整数。输入一个正整数Q(<=2000),接着输入Q行,每行包括两个数字代表集合的编号,每次询问输出两个集合的重复率(保留一位小数,重复率等于两个集合相同的数字个数除以两个集合合并为一个集合的话集合内数字的个数)。

AAAAAccepted code:

 #define HAVE_STRUCT_TIMESPEC
#include<bits/stdc++.h>
using namespace std;
int a[][];
set<int>st[];
int b[][];
int cnt[];
int main(){
int n;
cin>>n;
for(int i=;i<=n;++i){
int x;
cin>>x;
for(int j=;j<=x;++j){
cin>>a[i][j];
if(!st[i].count(a[i][j])){
st[i].insert(a[i][j]);
b[i][++cnt[i]]=a[i][j];
}
}
}
int q;
cin>>q;
while(q--){
int x,y;
cin>>x>>y;
if(cnt[y]<cnt[x])
swap(x,y);
int tamp=;
int sum=cnt[x]+cnt[y];
for(int i=;i<=cnt[x];++i)
if(st[y].count(b[x][i]))
++tamp;
double ans=100.0*tamp/(sum-tamp);
printf("%.1f%\n",ans);
}
return ;
}

【PAT甲级】1063 Set Similarity (25 分)的更多相关文章

  1. PAT 甲级 1063 Set Similarity (25 分) (新学,set的使用,printf 输出%,要%%)

    1063 Set Similarity (25 分)   Given two sets of integers, the similarity of the sets is defined to be ...

  2. PAT 甲级 1020 Tree Traversals (25分)(后序中序链表建树,求层序)***重点复习

    1020 Tree Traversals (25分)   Suppose that all the keys in a binary tree are distinct positive intege ...

  3. PAT 甲级 1146 Topological Order (25 分)(拓扑较简单,保存入度数和出度的节点即可)

    1146 Topological Order (25 分)   This is a problem given in the Graduate Entrance Exam in 2018: Which ...

  4. PAT 甲级 1071 Speech Patterns (25 分)(map)

    1071 Speech Patterns (25 分)   People often have a preference among synonyms of the same word. For ex ...

  5. PAT 甲级 1059 Prime Factors (25 分) ((新学)快速质因数分解,注意1=1)

    1059 Prime Factors (25 分)   Given any positive integer N, you are supposed to find all of its prime ...

  6. PAT 甲级 1051 Pop Sequence (25 分)(模拟栈,较简单)

    1051 Pop Sequence (25 分)   Given a stack which can keep M numbers at most. Push N numbers in the ord ...

  7. PAT 甲级 1048 Find Coins (25 分)(较简单,开个数组记录一下即可)

    1048 Find Coins (25 分)   Eva loves to collect coins from all over the universe, including some other ...

  8. PAT 甲级 1037 Magic Coupon (25 分) (较简单,贪心)

    1037 Magic Coupon (25 分)   The magic shop in Mars is offering some magic coupons. Each coupon has an ...

  9. PAT 甲级 1028 List Sorting (25 分)(排序,简单题)

    1028 List Sorting (25 分)   Excel can sort records according to any column. Now you are supposed to i ...

  10. PAT 甲级 1024 Palindromic Number (25 分)(大数加法,考虑这个数一开始是不是回文串)

    1024 Palindromic Number (25 分)   A number that will be the same when it is written forwards or backw ...

随机推荐

  1. php抛出异常Exception和\Exception使用区别

    没有定义命名空间的情况下 , Exception和\Exception 均可正常执行抛出异常;定义命名空间的情况 , Exception 会在定义的命名空间下找对应的异常类 , 如果没有定义异常类 , ...

  2. Bugku-一段Base64-Writeup

    转载请注明出处:http://www.cnblogs.com/WangAoBo/p/7207874.html bugku - 一段Base64 - Writeup 题目: 分析: 本来看到题目名字和分 ...

  3. 8.10-Day2T2 吃喝大法好

    题目大意 略... 题解 开始两个人一定是一个向右走一个向下走,向右走的人最终会走到(n-1,m),向下走的人一定会走到(n,m-1). 那么不考虑重复的话总的路径数就是从(1,2)到(n-1,m)的 ...

  4. Spring Security技术栈开发企业级认证与授权(一)环境搭建

    本项目是基于慕课网的Spring Security技术栈开发企业级认证与授权,采用IDEA开发,本文章用来记录该项目的学习过程. 慕课网视频:https://coding.imooc.com/clas ...

  5. c语言thread用法记录。

    https://blog.csdn.net/hitwengqi/article/details/8015646 先是c++11之前的 1.最基础,进程同时创建5个线程,各自调用同一个函数 #inclu ...

  6. Django框架-模型层

    Django框架-模型层 一.单表查询之必知必会13条 1.时间字段中的两个关键性参数 create_time = models.DateField() # 年月日 create_time = mod ...

  7. html标签的快捷

    https://www.jianshu.com/p/8f330e3571ee 一: <ul> <li><a href=""></a> ...

  8. 数据库程序接口——JDBC——功能第五篇——批量处理

    综述 批量处理一般指批量插入,批量更新,删除通过可以指定where条件实现.批量插入的实现方式有三种类型.statement,preparedStatement,callableStatement. ...

  9. STM32程序中 \r \n \r\n

    1.用串口调试助手打印信息,程序换行时,最好还是用\r\n,光用\r或光用\n可能达不到换行的效果.

  10. Spring IoC(三)bean属性、方法注释

    1.环境配置 使用注解开发jdk1.5.Spring2.5支持,在xml中添加context相关的是四个配置; <beans default-lazy-init="true" ...