cf 464 A. Love Triangle

使用单片机开发PWM的案例&相关项目源码 该项目使用STM32单片机生成PWM信号,通过改变PWM的占空比来控制连接在PWM输出引脚(如PA0)上的LED的亮度。在主循环中,通过改变比较值,PWM信号的占空比在0%到100%之间变化,从而实现LED亮度的渐变效果。这个项目是一个基础的PWM控制示例,通过学习和实践这个项目,可以掌握PWM的基本原理和使用方法,并为进一步开发和应用打下良好的基础。该项目实现了使用STM32单片机产生PWM信号,并通过改变PWM的占空比来控制LED的亮度。配置PWM输出引脚(如PA0),确保其模式为PWM输出。 阅读详情
A. Love Triangle
time limit per test
1 second
memory limit per test
256 megabytes
input
standard input
output
standard output

As you could know there are no male planes nor female planes. However, each plane on Earth likes some other plane. There are n planes on Earth, numbered from 1 to n, and the plane with number i likes the plane with number fi, where 1 ≤ fi ≤ n and fi ≠ i.

We call a love triangle a situation in which plane A likes plane B, plane B likes plane C and plane C likes plane A. Find out if there is any love triangle on Earth.

Input

The first line contains a single integer n (2 ≤ n ≤ 5000) — the number of planes.

The second line contains n integers f1, f2, ..., fn (1 ≤ fi ≤ n, fi ≠ i), meaning that the i-th plane likes the fi-th.

Output

Output «YES» if there is a love triangle consisting of planes on Earth. Otherwise, output «NO».

You can output any letter in lower case or in upper case.

Examples
Input
Copy
5
2 4 5 1 3
Output
YES
Input
Copy
5
5 5 5 5 1
Output
NO
Note

In first example plane 2 likes plane 4, plane 4 likes plane 1, plane 1 likes plane 2 and that is a love triangle.

In second example there are no love triangles.


#include <cstdio>
#include <iostream>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <vector>
#include <queue>
using namespace std;
#define INF 0x7f
const int maxn =10005; 
typedef long long ll ;
#define f(i,l,r) for(int i=l;i<=r;++i)
#define g(i,l,r) for(int i=l;i>=r;--i)
int n ;
int a[maxn];
bool flag=false;
int main()
{
	cin>>n;
	f(i,1,n)
		cin>>a[i];
	f(i,1,n)
	{
		if(a[a[a[i]]]==i)
			flag=true;
	}
	 if(flag)cout<<"YES"<<endl;
	 else cout<<"NO"<<endl;

	return 0;

}
未来的我一定会感谢现在正在成长的我




uniApp微信小程序:error: 60001 request:fail errcode:-101 cronet error code:-101error_msg:net::ERR CONNECTI uni-app微信小程序域名访问报error 60001 request:fail errcode:-101,解决Uniapp微信小程序报600001错误,uni.request()接口请求报错,服务器更换SSL证书后,uniapp微信小程序出现`request:fail errcode:-101`问题分析与解决,服务器更换ssl证书后,手机访问微信小程序异常,微信小程序更换SSL证书后出现请求报错,服务器更换SSL证书,微信小程序报600001,小程序反应偶尔出现request:fail errcode: 阅读详情

相关推荐

机器学习实例(预测房价中位数)(附代码)

1、下载数据: 下载一个压缩文件housing.tgz即可,其包含housing.csv(已经包含书有数据。),用 tax xzf housing.tgz 来解压提取CSV文件。 import os import tarfile import urllib.request DOWNLOAD_ROOT = "https://raw.githubusercontent.com/ageron/handson-ml2/master/" HOUSING_PATH = os.path.join("datasets",

qq_51153436的博客 2760

Love Triangle (三角恋) Visual Judge (Set3)

文章目录题目描述输入描述输出描述输入输出样例线索提示一、解题思路二、题解源代码VJudge评判结果写在最后 题目描述 Love Triangle (三角恋) 告诉你每个人喜欢谁,问你这堆人里面有没有三角恋存在 输入描述 第一行输入一个整数N(2≤  N  ≤5000),表示有N个人 第二行输入整数F1,F2,F3,⋯  ,FN  (1⩽Fi⩽N,Fi≠i)F_1,F_2,F_3, \cdots \,\,,F_N\,\,\left( 1\leqslant F_i\leqslant N,F_i\ne i .

LeungSr的博客 643

CCS TMSC6748 报错Error connecting to the target: (Error -600 @ 0x0)

CCS TMSC6748 报错Error connecting to the target:(Error -600@ 0x0)

AS_the_deer1717的博客 6636

Codeforces Round #464 (Div. 2)A. Love Triangle

简答题但会想复杂

P0rscher的博客 261

实战详细讲解Qt插件plugin的编写与用法

qt插件的开发,可以说是动态库的开发,因为调用方式类似,多熟悉一下,利用Qt框架开发很简单的。在想想这种调用过程有的熟悉,比如公司买了一堆摄像头,公司要对摄像头进行二次开发,实现自己想要的功能,集成到一套设备里去,然后在卖给用户。此时厂商肯定会提供开发文档,并给你SDK包(软件开发工具包), 包里你会发现只有头文件和一堆库文件,没有源文件,因为实现的过程是产商公司保密的,给你看还得了。所以都封装成了库的形式给你调用,如静态库或者动态库。

qq_44667165的博客 1万+

SpringBoot整合海康SDK实战:从设备初始化到PS流录像转MP4全流程(附避坑指南)

本文详细介绍了SpringBoot整合海康SDK的完整实战流程,涵盖设备初始化、通道管理、录像检索与下载。针对海康设备生成的PS流录像文件无法直接播放的痛点,重点解析了如何利用FFmpeg高效、无损地将其转换为通用的MP4格式,并提供了关键的避坑指南和性能优化建议。

chair的专栏 764

Codeforces--939A--Love Triangle

题目描述: As you could know there are no male planes nor female planes. However, each plane on Earth likes some other plane. There are n planes on Earth, numbered from 1 to n, and the plane with number i likes the plane with number f i, where 1 ≤ f i ≤ n and f

猩猩是个好程序员的博客 332

STM32H745xI双核芯片SMPS/LDO配置误区:从复位失败到精准排查的实战复盘

本文详细分析了STM32H745xI双核芯片在SMPS/LDO配置中的常见误区,特别是复位失败问题的排查过程。通过对比参考板与故障板的波形数据,揭示了电感选型不当导致的电源稳定性问题,并提供了硬件设计检查清单和调试技巧,帮助开发者避免类似陷阱。

weixin_42531588的博客 265

A. Love Triangle

As you could know there are no male planes nor female planes. However, each plane on Earth likes some other plane. There are n planes on Earth, numbered from 1 to n, and the plane with number i likes ...

码农的一亩三分地 422

嵌入式开发避坑指南:用DWT做延时函数,这几个细节不注意代码会跑飞

本文深入探讨了在Cortex-M嵌入式开发中使用DWT实现精确延时函数的关键技巧与常见陷阱。针对DWT_CYCCNT计数器应用中的内核兼容性、溢出处理、编译器优化等五大核心问题,提供了工业级稳健解决方案,帮助开发者避免代码跑飞风险,实现微秒级高精度延时控制。

weixin_42653691的博客 160

莆田市C++专项选拔第一轮题4

现在小明同学想要从两堆硬币中各选择一枚硬币,使得两枚硬币的面值之和 不超过 k。不同的硬币组合,就算面值相同,也视为不同的方案。现在他把这些硬币分成了两堆,已知两堆硬币分别有 n 和 m 枚硬币。可选方案有: (1,2), (1,1), (1,1), (5,2), (5,1), (5,1),共 6 种。第一行三个整数 n, m, k,分别表示第一堆硬币的数量,第二堆硬币的数量,以及面值之和的上限。对于30%的数据,1 ≤ n , m ≤ 1000 , 1 ≤ b , c ≤ 1000。

lpstudio的博客 925

Codeforces Round #464 (Div. 2) A. Love Triangle 水题

A. Love Triangletime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputAs you could know there are no male planes nor female planes. However, each plane o...

Frost_Bite的博客 564

C-Lodop打印服务系统存在任意文件读取

C-Lodop打印服务系统存在任意文件读取

weixin_43567873的博客 2875

Codeforces 939A Love Triangle(三角恋问题)

题目:As you could know there are no male planes nor female planes. However, each plane on Earth likes some other plane. There are n planes on Earth, numbered from 1 to n, and the plane with number i like

Puppet__的博客 1315

最新的sdio 4.0 spec 协议标准 带书签 高清完整PDF版

Part-E1-SDIO-Specification-Ver4.00-Final-120220.pdf:最新的sdio 4.0 spec 协议标准 带书签 高清完整PDF版,包括SDIO 接口的外设,SDIO 接口官方协议等。

假人有限元模型

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

CF 939A Love Triangle

A. Love TriangleAs you could know there are no male planes nor female planes. However, each plane on Earth likes some other plane. There are n planes on Earth, numbered from 1 to n, and the plane with...

XYANG5204的博客 478

VB摄像头监控

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

CodeForces-939A

链接: https://vjudge.net/problem/CodeForces-939A 题意: As you could know there are no male planes nor female planes. However, each plane on Earth likes some other plane. There are n planes on Earth, ...

weixin_30693683的博客 157

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

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

L - Love Triangle

As you could know there are no male planes nor female planes. However, each plane on Earth likes some other plane. There arenplanes on Earth, numbered from1ton, and the plane with numberilikes ...

Luoriliming的博客 399

Codeforces Round #464 (Div. 2) A-D题解

A. Love Triangle time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output As you could know there are no male...

weixin_30807677的博客 262

Codeforces Round #464 (Div. 2) ABCDE

A. Love Triangletime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputAs you could know there are no male planes nor female planes. However, each plane o...

J. Cole 529

CodeForces - 939A Love Triangle (暴力水题)

Love Triangle As you could know there are no male planes nor female planes. However, each plane on Earth likes some other plane. There arenplanes on Earth, numbered from1ton, and the plane wi...

YOONGI 506

CodeForces 939A(水题)

DescriptionAs you could know there are no male planes nor female planes. However, each plane on Earth likes some other plane. There are n planes on Earth, numbered from 1 to n, and the plane with numb...

Aurora 565

Triangle LOVE

 http://acm.hdu.edu.cn/showproblem.php?pid=4324 #include #include #include using namespace std; int indegree[2010]; char map[2010][2010]; int main() {  int t,n;  int k,i,j;  cin>>t;  fo

shuangyueliao的专栏 754

HDU 4324 topological_sort

Triangle LOVE Time Limit:1000MS Memory Limit:65536KB 64bit IO Format:%I64d & %I64u Submit Status Description Recently, scientists find that there is love between any of two people. For exa...

weixin_30879169的博客 175

Triangle Love

E - Triangle LOVE  HDU - 4324  #include &lt;stdio.h&gt; #include &lt;string.h&gt; char a[2001][2001]; int main() { int t,i,l,n,q,w,j,k; scanf("%d",&amp;t); for(w=0;w&lt;t;w++) { q=0; sca...

qq_42434171的博客 307

Triangle LOVE(HDU-4324)

Problem Description Recently, scientists find that there is love between any of two people. For example, between A and B, if A don’t love B, then B must love A, vice versa. And there is no possibili...

Alex_McAvoy的博客 382

Triangle LOVE 【topo 判有无环】

Recently, scientists find that there is love between any of two people. For example, between A and B, if A don’t love B, then B must love A, vice versa. And there is no possibility that two people love

lzs_lazy 383
上一篇: cf 464 B. Hamster Farm
下一篇: cf 468 C. Convenient For Everybody
PragIncor
博客等级 码龄9年 1粉丝 59原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

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

抵扣说明:

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

余额充值