You are my brother
问题 : You are my brother
时间限制: 1 Sec 内存限制: 128 MB
题目描述
Little A gets to know a new friend, Little B, recently. One day, they realize that they are family 500 years ago. Now, Little A wants to know whether Little B is his elder, younger or brother.
输入
There are multiple test cases.
For each test case, the first line has a single integer, n (n<=1000). The next n lines have two integers a and b (1<=a,b<=2000) each, indicating b is the father of a. One person has exactly one father, of course. Little A is numbered 1 and Little B is numbered 2.
Proceed to the end of file.
输出
For each test case, if Little B is Little A’s younger, print “You are my younger”. Otherwise, if Little B is Little A’s elder, print “You are my elder”. Otherwise, print “You are my brother”. The output for each test case occupied exactly one line.
样例输入
5 1 3 2 4 3 5 4 6 5 6 6 1 3 2 4 3 5 4 6 5 7 6 7
样例输出
You are my elder You are my brother
解题思路
根据所给的数对,判断1,2分别组成的链的长短。
#include <stdio.h> #include <string.h> int main() { int n, a, b; int s[2010]; while (~scanf("%d", &n)) { memset(s, 0, sizeof(s)); for (int i = 0; i < n; i++) { scanf("%d%d", &a, &b); s[a] = b; } a = 1; b = 2; while (s[a] && s[b]) { a = s[a]; b = s[b]; } if (!s[a] && s[b]) puts("You are my younger"); else if (!s[a] && !s[b]) puts("You are my brother"); else puts("You are my elder"); } return 0; }
You are my brother的更多相关文章
- fzoj1314 You are my brother
题目描述 Little A gets to know a new friend, Little B, recently. One day, they realize that they are fam ...
- 远程监控显示brother数控机床数据
最近几个月公司太忙了,到现在已经连续出差两个多月了. 这个项目这要做mes系统,涉及到产品在机床的加工过程监控,然后led看板显示产品进度. 这里的主角是日本的brother数控机床,服务器按照一定频 ...
- Ubuntu 安装 Brother MFC7470D 驱动
Ubuntu 安装 Brother MFC7470D 驱动 办公室的打印机是 Brother MFC7470D ,在 Ubuntu 中安装打印机驱动时,发现没有这个型号的驱动.只有 MFC7450 的 ...
- FJNU 1154 Fat Brother And His Love(胖哥与女神)
FJNU 1154 Fat Brother And His Love(胖哥与女神) Time Limit: 2000MS Memory Limit: 257792K [Description] [ ...
- FJNU 1153 Fat Brother And XOR(胖哥与异或)
FJNU 1153 Fat Brother And XOR(胖哥与异或) Time Limit: 1000MS Memory Limit: 257792K [Description] [题目描述] ...
- FJNU 1155 Fat Brother’s prediction(胖哥的预言)
FJNU 1155 Fat Brother’s prediction(胖哥的预言) Time Limit: 1000MS Memory Limit: 257792K [Description] [ ...
- FJNU 1152 Fat Brother And Integer(胖哥与整数)
FJNU 1152 Fat Brother And Integer(胖哥与整数) Time Limit: 1000MS Memory Limit: 257792K [Description] [题 ...
- FJNU 1156 Fat Brother’s Gorehowl(胖哥的血吼)
FJNU 1156 Fat Brother’s Gorehowl(胖哥的血吼) Time Limit: 1000MS Memory Limit: 257792K [Description] [题目 ...
- FJNU 1151 Fat Brother And Geometry(胖哥与几何)
FJNU 1151 Fat Brother And Geometry(胖哥与几何) Time Limit: 1000MS Memory Limit: 257792K [Description] [ ...
- FJNU 1157 Fat Brother’s ruozhi magic(胖哥的弱智术)
FJNU 1157 Fat Brother’s ruozhi magic(胖哥的弱智术) Time Limit: 1000MS Memory Limit: 257792K [Description ...
随机推荐
- gradle文件中自定义字段值在java代码中使用
1. 在build.gradle 中 buildConfigField 的参数有3个 第一个类型 第二个为名称 第三个是值 如果是字符串类型 请不要忘记 双引号! buildTypes { ...
- 《SSH网上商城》-视频目录--代码可以跑起来
本课程是2015年2月份的,就是14年底的. 课程第一天的代码-添加 jsp-api.jar servlet-api.jar就可以跑起来,环境 JDK1.7 和tomcat8, SSH网上商城\S ...
- Django学习手册 - 权限管理(二)
从数据库获取数据后,对数据进行清洗 目标: 数据1,存放至session 中的数据 数据2,显示至前端的菜单数据 清洗数据: 1.session存放的数据:(menu_leaf_dict) 2.前端菜 ...
- synchronized与Lock的区别与使用
1.ReentrantLock 拥有Synchronized相同的并发性和内存语义,此外还多了 锁投票,定时锁等候和中断锁等候 线程A和B都要获取对象obj的锁定,假设A获取了对象obj锁,B将等待A ...
- Javascript - ExtJs - XTemplate组件
XTemplate组件(Ext.XTemplate) 如果有一些重复的html代码需要装入数据,可以考虑使用XTemplate模板组件.XTemplate可以填入数组.对象,支持条件判断.for循环. ...
- windows下flazr对rtmp视频流进行压力测试(批量直播测试)
flazr-0.7-RC2下载地址:百度网盘 提取码:nu05 简述:通过推流软件推送摄像头视频流到nginx流媒体服务器,获取nginx流媒体服务器上的视频流,在windows下使用flazr软件进 ...
- [Harbor]Docker登录Harbor仓库(HTTP方式)
Docker登录到Harbor仓库时,不管是使用http协议还是使用https协议,都需要修改一些配置. 这篇文章来介绍一下,在使用http协议时,需要进行什么哪些配置. 首先,确定自己的Harbor ...
- 【原理】VRRP详解
写在前面 keepalived是一个基于VRRP协议来实现的服务高可用方案,从而可以避免IP单点故障.一般与其他负载均衡技术,如LVS,Nginx等一起来工作来达到集群高可用的目的 关于Keepali ...
- MFC调用libyara遇到的问题
测试结果 如果调用yara非要变成共享DLL的形式,加那么多的DLL,不如直接调用EXE文件.反而依赖vcruntime运行库的DLL会少很多... 调用libyara 调用libraya和C++调用 ...
- [BugBounty] Sleeping stored Google XSS Awakens a $5000 Bounty
来源:https://blog.it-securityguard.com/bugbounty-sleeping-stored-google-xss-awakens-a-5000-bounty/ 理解 ...