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),每个作业需耗时,有一个截止期限.超期多少天就要扣多少 ...
随机推荐
- java.lang.ClassNotFoundException: com.microsoft.jdbc.sqlserver.SQLServerDriver
今天这个问题排查了好大一会,开始网上有人这么说: https://www.cnblogs.com/rookiebob/p/3749396.html 但是仍未能解决我的问题, 最后发现是只在外层的pom ...
- JavaScript变量声明提升
JavaScript代码在被解析引擎执行前,会被“编译”把变量声明等放在合适的作用域中,如果不了解这一点,会让人产生很多疑惑. 文章:详解js变量声明提升
- hihoCoder#1105 题外话·堆
原题地址 有没有更优雅地堆模板啊,总感觉我写的有些啰嗦 代码: #include <iostream> using namespace std; #define MAX_NODE 1000 ...
- HDU 2767 Proving Equivalences(强连通 Tarjan+缩点)
Consider the following exercise, found in a generic linear algebra textbook. Let A be an n × n matri ...
- OC温习四:数组
/** arrayByAddingObject -- 往数组A添加一个数据,返回一个数组的形式,即必须有一个数组来接受 */ NSArray *array = [NSArray arrayWithOb ...
- django学习之- Cookie
cookie:客户端游览器上的一个文件,以键值对进行保存,类似字典{'k':'sfs'},与服务器端没有关系,当游览器访问服务器时候,服务器会生成一个随机字符串保存在cookie中返回给客户端,这样当 ...
- [Bzoj4817] [Sdoi2017]树点涂色 (LCT神题)
4817: [Sdoi2017]树点涂色 Time Limit: 10 Sec Memory Limit: 128 MBSubmit: 629 Solved: 371[Submit][Status ...
- Shiro note
我们需要实现Realms的Authentication 和 Authorization.其中 Authentication 是用来验证用户身份,Authorization 是授权访问控制,用于对用户进 ...
- Linux驱动开发:USB驱动之usb_skel分析
在学习了这么些天的驱动之后,个人觉得驱动就是个架构的问题,只要把架构弄清楚了 然后往里面添砖加瓦就可以了,所以似乎看起来不是太困难,但也许是是我经验不足吧,这只能算是个人浅见了 这两天在学习USB驱动 ...
- Linux系统启动流程分析
作者:郭孝星 微博:郭孝星的新浪微博 邮箱:allenwells@163.com 博客:http://blog.csdn.net/allenwells Github:https://github.co ...