题意:

输入一个正整数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. sqlserver 查看视图语句

    本人sql小白一个,在项目中遇到了视图的使用,但是不知道视图的语句怎么查看,所以在网上搜索了一下,查到了一下的查看方式,再次记录一下: 方法一->前提: 已经创建好的视图 sp_helptext ...

  2. MS Sqlserver删除字段最后的多余字符

    存在这样一些数据 ,,,,dga bc,,aaaa,,,,,,,,dga bc,,aaaa,,,,,,,dga bc,,aaaa,,,,,,,dga bc,,aaaa,,,,,, 需要将最后多余的逗号 ...

  3. Tomcat目录说明

    apache-tomcat-x.x.xx bin:保存启动与监控Tomcat的命令文件的文件夹 conf:保存Tomcat配置文件的文件夹,如servlet.xml为服务器的主配置文件,web.xml ...

  4. bugku flag在index里

    原题内容: http://120.24.86.145:8005/post/ Mark一下这道题,前前后后弄了两个多小时,翻了一下别的博主的wp感觉还是讲的太粗了,这里总结下自己的理解: 首先打开这道题 ...

  5. 概率dp sgu495

    题意: 有n个奖品,m个人排队来选礼物,对于每个人,他打开的盒子,可能有礼物,也有可能已经被之前的人取走了,然后把盒子放回原处.为最后m个人取走礼物的期望. 思路1: 排队取,第1个人取到1个,dp[ ...

  6. ASA映射80端口到公网

    1.测试拓扑: 2.测试目的:Web Server:192.168.1.100/24 GW:192.168.1.254Internet:200.1.1.2/24 映射的地址:200.1.1.3 3.配 ...

  7. React 实现input输入框的防抖和节流

    1.为什么使用防抖和节流对于频繁触发的事件 比如keydown keyup事件 当频繁点击时候 会多次触发事件 页面出现卡顿 影响性能 2.函数防抖(debounce):间隔时间内只执行一次   函数 ...

  8. Java 常见异常及处理方案

    Java 常见异常处理方案 异常是程序中的一些错误,但并不是所有的错误都是异常,并且错误有时候是可以避免的. 比如说,你的代码少了一个分号,那么运行出来结果是提示是错误java.lang.Error: ...

  9. 如何将博客内容输出到pdf

    可以按照三类网页插件:Clearly,Instapaper 和 Readability,实际安装发现,第一个装不上,只有最后一个好用.在firefox或者chrom浏览器装好后,右键switch to ...

  10. find 报错 find: paths must precede expression:

    编写shell脚本,报错,如下面 [root@localhost backup]#find ./ -name mysqldump* -mtime +3 -delete [root@localhost ...