PAT a1120

蓝牙钥匙中继攻击原理与防护:从RTT测距到射频指纹的实战方案 蓝牙BLE技术已广泛用于智能门锁、汽车无钥匙进入和共享设备,为用户带来无感开锁体验的同时,也引入了新的无线安全风险。其中,中继攻击(Relay Attack)不破解加密算法、不窃取密钥,仅通过实时转发合法钥匙与锁之间的信号,就能在数百米外实现开锁,且现场不留痕迹。这种攻击利用的是传统方案依赖RSSI判断距离的信任盲区,因此密码学强度再高也难以防御。要构建可靠的防护体系,需要从物理层到决策层进行纵深设计:基于信号往返时间(RTT)的距离边界协议可有效识别中继链路带来的额外时延,射频指纹技术则能区分真实钥匙与转 阅读详情

目的:输出Friend id

输入:

N 输入的整数个数

输出:

输出这一串数字里面的Friend ID 

#include<iostream>
#include<stdio.h>
#include<string>
#include<set>

using namespace std;

set<int> ans;
int N;

int main()
{
    scanf("%d",&N);

    for(int i=0;i<N;i++)
    {
        string s;
        cin>>s;
        int id = 0;
        for(int i=0;i<s.length();i++)
        {
            id += s[i] - '0';
        }
        ans.insert(id);
    }
    printf("%d\n",ans.size());
    for(set<int>::iterator it = ans.begin();it!=ans.end();it++)
    {
        if(it!=ans.begin())
        printf(" ");
        printf("%d",*it);
    }
    return 0;
}

反思:用set,合并重复,按顺序排列。

PAT-A1120/B1064 Friend Numbers/朋友数 题目内容及题解 Two integers are called "friend numbers" if they share the same sum of their digits, and the sum is their "friend ID". For example, 123 and 51 are friend numbers since 1+2+3 = 5+1 = 6, and 6 is their ... 阅读详情

相关推荐

【PAT】A1120 Friend Numbers【散列】

Two integers are called “friend numbers” if they share the same sum of their digits, and the sum is their “friend ID”. For example, 123 and 51 are friend numbers since 1+2+3 = 5+1 = 6, and 6 is their ...

elegant coder 836

PAT A1120~A1123

一、PAT A1120Friend Numbers 很简单啦。把每个数的 friend id 算出来用集合保存,集合里面会自动排序,最后输出即可。参考代码如下。 #include&lt;cstdio&gt; #include&lt;set&gt; using namespace std; set &lt;int&gt; s; int main() { int n, t; scanf(...

Armstrong的博客 354

SIwave学习记录:电热耦合仿真

SIwave电热耦合仿真

m0_68174736的博客 2335

PAT(A) 1120. Friend Numbers (20)

原题目: 原题链接:https://www.patest.cn/contests/pat-a-practise/1120 1120. Friend Numbers (20) Two integers are called “friend numbers” if they share the same sum of their digits, and the sum ...

萧易桥的博客 259

ServiceNow Discovery & CMDB Interview Questions and Answers (2025)

【代码】ServiceNow Discovery & CMDB Interview Questions and Answers (2025)

weixin_47584092的博客 910

网络攻防实验——网络监听

利用CAIN实现ARP监听。

Trieyes_of_feng的博客 3196

PAT A1120 Friend Numbers

PAT A1120 Friend Numbers Sample Input: 8 123 899 51 998 27 33 36 12 Sample Output: 4 3 6 9 26 思路 1: 求出每个输入数各位数的和,insert入set 遍历set输出 code 1: #include <iostream> #include <set> usin...

qq_42347617的博客 176

Ubuntu-22.04安装VMware虚拟机并安装Windows10

最近在研究虚拟机,主要集中在KVM、Virtualbox和VMware这三种虚拟机上。前面我已经研究了前两种虚拟机的安装和使用方式,这篇文章介绍3兄弟中最后一个虚拟机安装和使用方式。Virtualbox虚拟机安装和使用KVM虚拟机安装和使用相比于前两种,VMware的安装方式最麻烦,但是综合体验下来我感觉流畅度最好。如果你确实有在Linux上使用VMware虚拟机的需求,那不妨跟着我看下去吧。1、gcc版本和内核版本一定要匹配上,否则会出各种错误。

jiexijihe945的博客 4115

PAT A1120

水题,没什么可说的 #include&lt;iostream&gt; #include&lt;stdlib.h&gt; #include&lt;stdio.h&gt; #include&lt;vector&gt; using namespace std; using std::vector; const int maxn=100; boo...

weixin_34066347的博客 92

PCIe 6.0 – 关于 PCI Express Gen6 您需要知道的一切

幸运的是,PCIe 6.0 FEC 足够轻,对延迟的影响最小。在电气层上,PCIe 6.0 使用 PAM4 信号(“四级脉冲幅度调制”),每个时钟周期将 2 位组合为 4 个幅度级别(00、01、10、11),与 PCIe 5.0 和前几代相比,它使用 NRZ 调制,每个时钟周期 1 位和两个幅度级别 (0, 1)。虽然 PAM4 信号更容易出错,但由于调制技术的性质,与 PCIe 5.0 相比,通道损耗不受影响,因此 PCB 上 PCIe 6.0 信号的范围将与 PCIe 5.0 相同。

qq_43416206的博客 3431

计算机组成原理(第三版)唐朔飞-第五章输入输出系统-课后习题

计算机组成原理(第三版)唐朔飞-第五章输入输出系统-课后习题

weixin_45735391的博客 6万+

8个真正免费高质量PPT素材网站实战指南

PPT素材库是职场人高效表达的核心基础设施,其本质是视觉语言系统与内容工程的结合体。优质素材需满足可编辑性、商用合规性、场景适配性三大技术原理,才能支撑数据可视化、政务汇报、科技路演等高频专业场景。当前主流‘免费’平台普遍存在授权模糊、图层锁定、分辨率受限等问题,导致隐性成本远超时间节省。本文聚焦真实项目验证的8个站点,覆盖Slidesgo设计系统、Freepik SVG精准调用、PPT Fans本土化模板等关键能力,特别强化对图表可编辑性、字体嵌入兼容性、CC0/商业授权链路等工程师级要求,为PPT制作提

weixin_34054866的博客 322

全覆盖路径规划开源项目Clean-robot-turtlebot3关键函数解析(上)

本系列文章主要介绍全覆盖路径规划开源项目Clean-robot-turtlebot3的相关内容,包含如下四篇文章,分别介绍了开源项目Clean-robot-turtlebot3流程的概括总结、ROS坐标系常用坐标及其变换、Clean-robot-turtlebot3关键函数解析等内容。

慕羽★的博客 2778

PAT-A1120

#include #include using namespace std; int cal(int x){ int sum=0; while(x>0){ sum+=x%10; x/=10; } return sum; } int main(){ int i, n, t; setst; scanf("%d",&n); for(i=0;i<n;i++){ scanf("%d",&

qq_2918的博客 463

芒果YOLO11改进44:主干Backbone篇之MobileViT::结合最新 ICLR2022 顶会|轻量通用的MobileViT结构(一)Transformer,轻量级、通用且移动友好的视觉转换

MobileViT::结合最新 ICLR2022 顶会|轻量通用的MobileViT结构(一)Transformer,轻量级、通用且移动友好的视觉转换

包括YOLOv5、YOLOv7、YOLOv8等模型改进 370

VB摄像头监控

该VB模块可对摄像头捕获的画面进行录像等,可在创建的窗口进行控制

PAT_A_1120 Friend Numbers

此题比较基础,题意:给一个int类型的数,然后求每位的和(id),求所给的一组数中id有多少种,打印种类个数和所有id 思路:把求得的id插入set集合,set集合不允许有重复的元素,而且是自动排好序的,故适合解此题 代码: #include<iostream> #include<algorithm> #include<set> using namesp...

qq_42152681的博客 150

Data-Structures-and-Algorithm-Analysis-in-Java.pdf

作者: Weiss, Mark A. 出版社: Addison Wesley Data Structures and Algorithm Analysis in Java is an “advanced algorithms” book that fits between traditional CS2 and Algorithms Analysis courses. In the old ACM Curriculum Guidelines, this course was known as CS7. This text is for readers who want to learn good programming and algorithm analysis skills simultaneously so that they can develop such programs with the maximum amo...

PAT A1120. Friend Numbers

1120. Friend Numbers (20) 时间限制 400 ms 内存限制 65536 kB 代码长度限制 16000 B 判题程序 Standard 作者 CHEN, Yue Two integers are called "friend numbers" if they share the

u014226072的专栏 280

Camera2Demo

在Camera2 的基础上进行封装,使得Camera2一堆初始化逻辑与Activity分离,降低耦合度,完成预览拍照并保存的操作

廖雪峰Python教程[完整版]

廖雪峰的python教程整理的,已经排好版了,而且还是完整的,适合小白

PAT A1120 Friend Numbers 解题笔记

PAT A1120 Friend Numbers(20) Two integers are called “friend numbers” if they share the same sum of their digits, and the sum is their “friend ID”. For example, 123 and 51 are friend numbers since 1+2+3=5+1=6, and 6 is their friend ID. Given some numbers,

qq_41025696的博客 159
上一篇: PAT a1121
下一篇: PAT a1118
CSlerner
博客等级 码龄9年 153粉丝 55原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

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

抵扣说明:

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

余额充值