当前位置:网站首页>2022河南萌新联赛第(二)场:河南理工大学 J - 签到
2022河南萌新联赛第(二)场:河南理工大学 J - 签到
2022-07-19 20:30:00 【WA_自动机】
J - 签到
求序列中是否存在 a 、 b 、 c 、 d a、b、c、d a、b、c、d 满足 a + b + c = d a+b+c=d a+b+c=d,且一个数可以重复选取, 基
于以上条件可以直接对式子进行等价变形为 a + b = d − c a+b=d-c a+b=d−c,所以直接求所有可能的 a [ i ] + a [ j ] a[i] + a[j] a[i]+a[j] 和 a [ i ] − a [ j ] a[i] − a[j] a[i]−a[j] 中是否存在一对相等的值即可
#include<bits/stdc++.h>
using namespace std;
int a[1010];
int main()
{
int n;cin>>n;
for(int i=1;i<=n;i++) cin>>a[i];
set<int> b;
sort(a+1,a+n+1);
for(int i=1;i<=n;i++)
for(int j=1;j<i;j++)
b.insert(a[i]-a[j]);
for(int i=1;i<=n;i++)
for(int j=1;j<=n;j++)
if(b.count(a[i]+a[j]))
{
cout<<"YES";
return 0;
}
cout<<"No";
return 0;
}
边栏推荐
- 网络工程案例:CII公司的综合网络设计
- 2022年最新内蒙古建筑安全员模拟题库及答案
- grafana可视化配置图表histogram
- Project knowledge points
- 串的部分基本操作代码实现
- Redis high availability: do you call this the principle of master-slave architecture data synchronization?
- 泡泡玛特7天市值蒸发210亿港元,国内卖不动,出海前途未卜
- 记录一下十三届蓝桥杯嵌入式省赛题目
- Quick sort by hand
- Cannot make QOpenGLContext current in a different thread : PyQt多线程崩溃的解决方法
猜你喜欢
The application could not be installed: INSTALL_FAILED_USER_RESTRICTED
【详细教程】一文参透MongoDB聚合查询
DeFi 2.0的LaaS协议Elephant,或许是你熊市下为数不多的获利手段
开启创客教育课程建设的实体空间
Redis practice: skillfully use data types to achieve 100 million level data statistics
Sword finger offer 71: step jumping expansion problem
The basic operation of data tables in MySQL is very difficult. This experiment will take you through it from the beginning
Leetcode 69: climb stairs / jump steps
2022年全国最新消防设施操作员(初级消防设施操作员)模拟题及答案
实现统一账号登录,sonarqube集成ldap
随机推荐
Musk said that he had uploaded his brain to the cloud [the system may have been open source]
Kingbasees SQL language reference manual of Jincang database (3.2. data type comparison rules)
Y71. Chapter IV Prometheus large factory monitoring system and practice -- Prometheus server installation (II)
Redis 实战篇:巧用 Bitmap 实现亿级海量数据统计
基于BS架构的微博系统
Jincang database kingbasees SQL language reference manual (3.8. database object, 3.9. database object name and qualifier)
Come after me! Flutter realizes chasing animation
机器人时代发展大趋势对民众的影响
【golang从入门到实践】石头剪刀布游戏
The R language uses the gghistogram function of ggpubr package to visualize the grouping box diagram, add the grouping mean value, customize the grouping color, add the axial whisker diagram (rug), ad
LVGL 8.2 Tabview & Window
Code source du système vidéo court, séquence de chargement des fichiers principaux dans le projet uni app
Cannot make QOpenGLContext current in a different thread : PyQt多线程崩溃的解决方法
Spire.Office For Net 7.7.2 以及新闻
Vmware解决无法识别USB的问题
Oracle 里 TCP Socket (KGAS) 这个等待事件一般是什么导致?
記錄一下十三届藍橋杯嵌入式省賽題目
About the list loop (five ways of writing foreach)
20220718 安全帽、行人检测、数据集
2022/07/19 learning notes (Day11) method overload