YTU 1074: You are my brother
1074: You are my brother
时间限制: 1 Sec 内存限制: 128 MB
提交: 10 解决: 7
题目描述
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
总是望着曾经的空间发呆,那些说好不分开的朋友不在了,转身,陌路。 熟悉的,安静了, 安静的,离开了, 离开的,陌生了, 陌生的,消失了, 消失的,陌路了。
#include <iostream>
using namespace std;
#define MAX_LEN 2002
int main()
{
int a=0, b=0,n=0, count,arr[MAX_LEN],cnta, cntb,i;
while (cin >> n)
{
for (i = 0; i < MAX_LEN; i++)
arr[i] = 0;
count = 0;
while (count < n)
{
cin >> a >> b;
arr[a] = b;
count++;
}
cnta = 0,cntb = 0,i = 1;
while (arr[i] > 0 )
{
cnta ++;
i = arr[i];
}
i = 2;
while (arr[i] > 0 )
{
cntb ++;
i = arr[i];
}
if (cnta == cntb)
{
cout << "You are my brother" << endl;
}
else if (cnta > cntb)
{
cout << "You are my elder" << endl;
}
else if (cnta < cntb)
cout << "You are my younger" << endl;
}
return 0;
}
YTU 1074: 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 ...
- ytu 1057: 输入两个整数,求他们相除的余数(带参的宏 + 模板函数 练习)
1057: 输入两个整数,求他们相除的余数 Time Limit: 1 Sec Memory Limit: 128 MBSubmit: 177 Solved: 136[Submit][Status ...
- 远程监控显示brother数控机床数据
最近几个月公司太忙了,到现在已经连续出差两个多月了. 这个项目这要做mes系统,涉及到产品在机床的加工过程监控,然后led看板显示产品进度. 这里的主角是日本的brother数控机床,服务器按照一定频 ...
- lightoj 1074 spfa判断负环
Extended Traffic Time Limit:2000MS Memory Limit:32768KB 64bit IO Format:%lld & %llu Sub ...
- ytu 1058: 三角形面积(带参的宏 练习)
1058: 三角形面积 Time Limit: 1 Sec Memory Limit: 128 MBSubmit: 190 Solved: 128[Submit][Status][Web Boar ...
- NOJ 1074 Hey Judge(DFS回溯)
Problem 1074: Hey Judge Time Limits: 1000 MS Memory Limits: 65536 KB 64-bit interger IO format: ...
- 1074, "Column length too big for column 'err_solution' (max = 21845); use BLOB or TEXT instead"
一个注意点,就是sqlalchemy 使用create_all()建表的时候,要在 create_all()所在页面import那些表的model sqlalchemy.exc.Operational ...
- ytu 1980:小鼠迷宫问题(DFS 深度优先搜索)
小鼠迷宫问题 Time Limit: 2 Sec Memory Limit: 64 MB Submit: 1 Solved: 1 [Submit][Status][Web Board] Desc ...
- HDU 1074 (状态压缩DP)
题目链接: http://acm.hdu.edu.cn/showproblem.php?pid=1074 题目大意:有N个作业(N<=15),每个作业需耗时,有一个截止期限.超期多少天就要扣多少 ...
随机推荐
- FTS5与DIY
此文已由作者王荣涛授权网易云社区发布. 欢迎访问网易云社区,了解更多网易技术产品运营经验. FTS5简介 前文已经介绍了FTS3/FTS4,本文着重介绍它们的继任者FTS5. FTS5是在SQLite ...
- Lucene的例子
lucene爬数据库中的数据无非也是查询数据.所有我们用lucene搜索数据主要有下面几个步骤:(代码紧供参考) 一 , 从数据库中查数据 ====爬数据 ------------- ...
- iOS 混合变换旋转 CGAffineTransform
在ios 中, Core Graphics 提供了一系列的函数可以在一个变换的基础上做深层次的变换,如果做一个既要缩放又要旋转的变换,以下的方法比较实用. CGAffineTransformScale ...
- PostgreSQL 9.3.1 中文手册(解决关键词报错的问题)
http://www.postgres.cn/docs/9.3/sql-keywords-appendix.html
- mysql写入数据乱码问题的解决
mysql默认编码为latin. 我的mysql版本为5.6.安装路径下没有my.ini,但是有my-default.ini.其实mysql没有配置文件也是可以启动的,但是为了设置编码,需要将my-d ...
- Java中@SuppressWarnings注解用法(转)
背景: J2SE提供的最后一个注解是@SuppressWarnings.该批注的作用是给编译器一条指令,告诉它对被批注的代码元素内部的某些警告保持静默. @SuppressWarnings注解允许您选 ...
- Spring Boot项目错误:Error parsing lifecycle processing instructions
pom.xml文件错误:Error parsing lifecycle processing instructions 解决方法:清空.m2/repository下的所有依赖文件,重新下载即可解决该问 ...
- curl 中文乱码
curl 中文乱码 学习了:https://blog.csdn.net/thc1987/article/details/52583789 学习了: http://blog.itpub.net/2903 ...
- Java多线程导致的的一个事物性问题
业务场景 我们如今有一个类似于文件上传的功能.各个子网站接受业务,业务上传文件,各个子网站的文件须要提交到总网站保存.文件是按批次提交到总网站的,也就是说,一个批次以下约有几百个文件. 考虑到白天提交 ...
- Deepin-安装和卸载软件
一般默认厂商源安装软件 安装软件: 示例:sudo apt-get install xx 实例:sudo apt-get install nodejs 卸载软件: 示例:sudo apt-get -- ...