【PTA-A】1063 Set Similarity (25 分)(Set)

立创电赛C题:基于STM32的三端口DC-DC变换器设计与MPPT算法实现 本文详细解析了2021年立创电赛C题——基于STM32的三端口DC-DC变换器设计。文章从题目要求出发,系统阐述了采用双DC-DC电路(分别负责MPPT追踪与稳压)的硬件架构,并重点讲解了以STM32为核心、结合PID控制与扰动观察法(MPPT算法)的软件实现方案,为备赛者提供了完整的软硬件设计思路与调试经验。 阅读详情

Given two sets of integers, the similarity of the sets is defined to be N​c​​/N​t​​×100%, where N​c​​ is the number of distinct common numbers shared by the two sets, and N​t​​ is the total number of distinct numbers in the two sets. Your job is to calculate the similarity of any given pair of sets.

Input Specification:

Each input file contains one test case. Each case first gives a positive integer N (≤50) which is the total number of sets. Then N lines follow, each gives a set with a positive M (≤10​4​​) and followed by M integers in the range [0,10​9​​]. After the input of sets, a positive integer K (≤2000) is given, followed by K lines of queries. Each query gives a pair of set numbers (the sets are numbered from 1 to N). All the numbers in a line are separated by a space.

Output Specification:

For each query, print in one line the similarity of the sets, in the percentage form accurate up to 1 decimal place.

Sample Input:

3
3 99 87 101
4 87 101 5 87
7 99 101 18 5 135 18 99
2
1 2
1 3

Sample Output:

50.0%
33.3%
#include<iostream>
#include<set>
#include<algorithm>
using namespace std;
const int N = 55;
set<int> st[N];

void compare(int a, int b) {
	int diff = st[b].size(), same = 0;
	for (set<int>::iterator it = st[a].begin(); it != st[a].end();it++){
		if (st[b].find(*it) != st[b].end())same++;
		else diff++;
	}
	printf("%.1f%%\n", same * 100.0 / diff);
}


int main() {
	int n,m,temp;
	scanf("%d", &n);
	for (int i = 1; i <= n; i++) {
		scanf("%d", &m);
		for (int j = 0; j < m; j++) {
			scanf("%d", &temp);
			st[i].insert(temp);
		}
	}
	int k,a,b;
	scanf("%d", &k);
	for (int i = 0; i < k; i++) {
		scanf("%d %d", &a, &b);
		compare(a, b);
	}
	return 0;
}

 

具身智能:原理、算法与系统 第1章 具身智能的本质与范畴 从学术定义的角度,具身智能可被界定为"与物理环境进行有目的的能量与信息交换"的智能形式。这一定义揭示了具身智能的两个本质维度:信息处理维度与能量交互维度。与传统人工智能系统仅在信息空间操作不同,具身智能系统必须同时处理信息流与能量流,在物理约束下实现感知、认知与行动的统一。具身智能体具有三个核心构成要素:物理身体(Physical Body)、感知系统(Sensory System)与效应器(Effectors)。这三者共同构成了感知与行动的基础,使智能体能够通过物理交互而非纯粹符号操作来理解世界。 阅读详情

相关推荐

用MATLAB从零实现六足机器人步态仿真:交替三角与波动步态保姆级教程

本文详细介绍了如何使用MATLAB从零实现六足机器人的两种经典步态仿真:交替三角支撑步态和波动步态。通过参数定义、相位设置、运动轨迹生成和三维可视化等步骤,帮助读者掌握六足机器人步态规划的核心技术。教程包含完整代码和详细解析,适合机器人爱好者和相关专业学生学习实践。

weixin_26765363的博客 225

PTA-set(1063)

1063 Set Similarity (25 分) Given two sets of integers, the similarity of the sets is defined to be Nc/Nt×100%, where N cis the number of distinct common numbers shared by the two sets, and N tis the total number of distinct numbers in the two sets. Your j.

qq_45929428的博客 475

零基础小白Coze知识普及【新手必备资料!!】

AI智能体|扣子(Coze)工作流搭建【零基础小白Coze知识普及】 1、领取100+工作流源码!复制到扣子即可直接使用 2、AI认知+9节商业智能体拆解 3、500+各行业高质量提示词 4、超低价格使用即梦文生图图生视频和banana生图

Zhima0522的博客 3249

《斯坦福数据挖掘教程·第三版》读书笔记(英文版)Chapter 5 Link Analysis

来源:《斯坦福数据挖掘教程·第三版》对应的公开英文书和PPT。

qq_52370024的博客 835

AMD显卡跑MiniMax H3提速30%:SageAttention ROCm适配全记录

在Transformer架构的视频生成模型中,注意力计算往往是性能瓶颈,尤其当显存资源受限时,低精度量化与内核优化成为关键突破口。SageAttention通过将QK^T矩阵乘法量化为INT8,并以FP16/INT4表达注意力概率矩阵,在保证画质的前提下显著降低访存与计算开销,相比传统FlashAttention具备更高速度上限。这一技术价值在本地部署场景尤为突出——当用户使用非NVIDIA显卡运行大型视频模型时,通用优化库常因依赖CUDA而失效。本文聚焦AMD ROCm平台下的MiniMax H3视频生成

weixin_32238157的博客 264

2024年物联网嵌入式最新嵌入式期末大作业——家用智能晾衣杆,初面蚂蚁金服

在家用智能晾衣杆中,用户可以根据自身的需要,切换手动和自动两个模式。天气对应的接口对应心知天气的天气图,可以下载后:调整尺寸->调整透明度->用画图工具保存为单色位图->提取出点阵信息(如我用的zimoV2.2软件),将点阵信息,存到数组里,根据weather的信息,调用display.drawBitmap()方法就能打印出对应的天气了。该库依赖于,将他们导入后,设置屏幕的主从关系,片选信号和数据,时钟信号等引脚后,就设置好屏幕的驱动。

2401_85013604的博客 1247

使用spark计算文档相似度

为什么80%的码农都做不了架构师?>>> ...

weixin_34405354的博客 2586

Python爬虫应对Cloudflare防护:5秒盾+Turnstile验证码实战(AST反混淆+指纹模拟,成功率95%)

Cloudflare 5秒盾+Turnstile验证码的防护核心,是通过“前端JS挑战+多维度指纹校验”确认请求来源的真实性。用AST反混淆还原CF的验证逻辑,避免执行无用代码导致的验证失败;基于真实浏览器采集指纹,确保指纹维度100%匹配真人环境;结合轻量级JS引擎和自动化工具,模拟完整的浏览器执行环境。该方案的绕过成功率可达95%(剩余5%主要是IP或请求频率导致的风控),适用于绝大多数部署CF防护的网站。

专注于Python爬虫开发,分享爬虫技巧、项目实战与反爬经验,使用Scrapy、BeautifulSoup等工具,解决数据抓取难题。 1713

python自然语言处理-学习笔记(三)之文本相似度计算

''' 文本相似度计算方法 ''' #1,编辑距离计算 ''' 是指两个字符串之间,由一个转成另一个所需的最少操作次数,如果它们就 距离越大,说明它们越不同,预科的编辑操作包括将一个字符替换成另一个字符,插入一个字符 删除一个字符 ''' import distance print(distance.levenshtein('setting','string')) #2 #第一步在s和t之...

pyswt的博客 2371

基于Jeecgboot3.9.0的文档管理系统(四)

基于Jeecgboot3.9.0的文档管理系统(四)

宁波阿成的博客 247

uniapp H5刷新页面后返回按钮失效问题完美解决方案

这个问题其实很隐蔽,尤其是uniapp H5 场景下刷新导致栈清理,很多开发者一开始都懵掉了。uniapp 内部对「页面栈只有一个」时的返回逻辑是reLaunch;所以只要在这个分支里替换为自己的逻辑(比如),就能顺利实现预期。目前我在项目里已经跑通了,暂时没发现问题。不得不说,知道源码里这个逻辑后,真的是醍醐灌顶,只能膜拜框架大佬了 🤯。

代码简单说 Vue、JAVA、PHP、Node.js 熟练运用,接口、架构、性能全搞定。 522

1063. Set Similarity (25)

题目: Given two sets of integers, the similarity of the sets is defined to be Nc/Nt*100%, where Nc is the number of distinct common numbers shared by the two sets, and Nt is the total number of d

Yangsongtao1991的专栏 655

飞塔CVE-2022-40684复现

admin 无密码直接回车(会提示修改密码)

G3et的博客 1144

PTA甲级 1063 Set Similarity (25分)-set的用法

文章目录题目原文Input Specification:Output Specification:Sample Input:Sample Output:生词如下:题目大意:思路如下:代码如下:柳神的思路:柳神的代码: 强烈推荐,刷PTA的朋友都认识一下柳神–PTA解法大佬 本文由参考于柳神博客写成 柳神的优快云博客,这个可以搜索文章 柳神的个人博客,这个没有广告,但是不能搜索 PS 今天也要加油鸭 题目原文 Given two sets of integers, the similarity of th

Huangpengyu123的博客 243

STM32F407中文手册

STM32f407中文手册 本参考手册面向应用开发人员,提供有关使用 STM32F405xx/07xx、STM32F415xx/17xx、 STM32F42xxx 和 STM32F43xxx 微控制器存储器与外设的完整信息。STM32F405xx/07xx、STM32F415xx/17xx、STM32F42xxx 和 STM32F43xxx 构成一个微 控制器系列,各产品具有不同的存储器大小、封装和外设。有关订购信息以及器件的机械与电气特性,请参见数据手册。有关 ARM Cortex™-M4F 内核的信息,请参见《Cortex™-M4F 技术参考手册》。

霍尼韦尔SoftMaster使用说明

霍尼韦尔SoftMaster使用说明

PAT A1063 Set Similarity (25)

PTA跳转:原题链接 题目大意是:比较两个集合的相似性。 输入:先输入一个数字m,然后要输入m组数据。接着输入一个数字n,然后输入n对数字。 输出:输出n个百分比数据。 本题考点是set,因为set容器内部元素有序且不重复,不用担心输入数据时有重复的元素。 我认为难点在于对题目,尤其是Nt的理解,原文“Nc is the number of distinct common numbers shar...

koori_145的博客 188

大中型超市收银系统(可直接运行)

光步前台收银系统系统功能:商品销售、商品退货、挂单、收银员权限、会员销售、单品取消、整单取消、商品查询、脱机销售、脱机数据上传,基本资料下载,开钱箱、小票打印、收款结算,支持多币种付款方式(现金、储值卡、礼券、微信等),支持多种促销。运行环境:.net 4.0登陆信息用户名:1001 密码:123456内置商品信息,商品编码可输入00001000 - 00010000,测试效果相关功能键F5 结算 F9挂单 F11商品查询 F8退货 Insert单品取消 Del整单取消 F12开钱箱F2 会员 Ctrl+Z退出系统 Home 锁屏 相关源码待公开

PAT甲级A1063 Set Similarity (25 分)

Given two sets of integers, the similarity of the sets is defined to be N​c​​/N​t​​×100%, where N​c​​ is the number of distinct common numbers shared by the two sets, and N​t​​ is the total number of ...

vir_lee的博客 243

假人有限元模型

假人模型,车辆碰撞假人有限元模型,适合做乘员安全的研究者利用

PTA甲级 1063 Set Similarity (C++)

Given two sets of integers, the similarity of the sets is defined to be Nc/Nt×100N_c/N_t ×100%Nc​/Nt​×100, where NcN_cNc​ is the number of distinct common numbers shared by the two sets, and NtN_tNt​ is the total number of distinct numbers in the two sets.

Misdirection 176

pat1063. Set Similarity

pat1063. Set Similarity

zero的博客 288

PTA 1063 Set Similarity

题目描述 分析: set集合的一个应用 #include<cstdio> #include<set> using namespace std; set<int> s[55]; int main(){ int n,k,x,y; scanf("%d",&n); for(int i=1;i<=n;i++){ scanf("%d",&k); for(int j=0;j<k;j++){ scanf("%d",&x);

qaqaqa666的博客 192

PTA甲级考试真题练习63——1063 Set Similarity

题目 思路 使用set自带的查找即可 代码 #include <iostream> #include<algorithm> #include<set> using namespace std; #define nmax 100001 #define inf 999999 vector<set<int>> vec; int main...

醉等佳人归 154

记录PTA甲级以及C++部分语法知识1063*-set

这题本来想用数组哈希写的,但是数值范围太大,不可行。 第一次接触set:https://www.cnblogs.com/omelet/p/6627667.html 代码源自:https://blog.youkuaiyun.com/hy971216/article/details/81368691 #include&lt;iostream&gt; #include&lt;set&gt; using na...

San_0303的博客 281

jaccard similarity coefficient 相似度计算

Jaccard index From Wikipedia, the free encyclopedia TheJaccard index, also known as theJaccard similarity coefficient(originally coinedcoefficient de communautébyPaul Jaccard), is a...

weixin_34072159的博客 370

PTA 悄悄关注 (函数使用,map,set)

L2-019 悄悄关注 (25 分) 分析: set函数加map函数,更快速地进行查找。 代码: #include &amp;lt;bits/stdc++.h&amp;gt; using namespace std; int main() { map &amp;lt;string, int&amp;gt; m; set &amp;lt;string&amp;gt; s; pair &amp;lt;string, int&amp;gt; p

圣诞老头的博客 722

Jaccard similarity

 The Jaccard index, also known as the Jaccard similarity coefficient (originally coined coefficient de communauté by Paul Jaccard), is a statistic used for comparing the similarity and diversity of

北极人的专栏 7073

PTA set 集合的“交”与“并”(set自带的方法)

给出两个由数字组成的集合,请求这两个集合的“交”和“并”。 输入格式: 给一个n,m 代表两个数列的大小 (0 <= n,m <=2e5) 如果n>0,则接下来一行, n个数空格隔开,代表第一个集合中的数。 如果m>0,则接下来一行, m个数空格隔开,代表第二个集合中的数。 -1e9<=ai,bi<=1e9 输出格式: 第一行首先输出两个数列交的集合中元素个数,如果元素个数大于0,则紧接着在这行输出“交集”的元素,按数值大小升序排列(本行输出多个数据时,用空格隔开,如果只

qq_45405490的博客 688

PAT a1063题解

#include #include using namespace std; const int N = 51; set st[N]; void compare(int x, int y){ int totalNum = st[y].size(), sameNum = 0; for(set::iterator it = st[x].begin(); it != st[x].end()

Tang's学习笔记 379
上一篇: Lunix磁盘扩大
下一篇: 【PTA-A】1060 Are They Equal (25 分)(String)
Netceor
博客等级 码龄9年 1046粉丝 306原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值