fzoj1314 You are my brother

题目描述

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>
#include<cstring>
using namespace std;
int main()
{
    int n;
    while(cin>>n)
    {
        int a,b,la=1,lb=2,da=0,db=0;
        for(int i=1;i<=n;i++)
        {
            cin>>a>>b;
            if(la==a){la=b;da++;}
            if(lb==a){lb=b;db++;}
        }
        if(db<da)cout<<"You are my elder"<<endl;
        else if(db==da) cout<<"You are my brother"<<endl;
        else if(db>da) cout<<"You are my younger"<<endl;
    }
    return 0;
}
时间: 2024-11-11 04:09:50

fzoj1314 You are my brother的相关文章

远程监控显示brother数控机床数据

最近几个月公司太忙了,到现在已经连续出差两个多月了. 这个项目这要做mes系统,涉及到产品在机床的加工过程监控,然后led看板显示产品进度. 这里的主角是日本的brother数控机床,服务器按照一定频率读取机床的生产数据,最基本的包括机床的工件产量,开机状态等信息. 后台是Java写的,其中一部分是led显示机床数据,而读取机床数据的部分本来想用dotnet做个Windows服务,可是折腾了很长时间还是没有搞定. brother机床设备里面是个Linux系统,里面架设有ftp服务,可以从远程pc

NBUT 1218 You are my brother(带权并查集)

#include<cstdio> #include<iostream> #include<cstring> #include<cmath> #include<queue> #include<stack> #include<algorithm> #include<stdlib.h> #define LL __int64 using namespace std; int fa[3000]; int val[3000

nyoj 282 You are my brother

You are my brother 时间限制:1000 ms  |  内存限制:65535 KB 难度:3 描述 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.

FJNU-1159 Fat Brother’s new way

Description I bet, except Fat Brothers, all of you don't like strange way to show integers , he is really like this way to showing integers: 1 -> 'A' 2 -> 'B' --. 26 -> 'Z' 27 -> 'AA' 28 -> 'AB' --. Unfortunately, Fat Brother's mathematics 

FJNU 1154 Fat Brother And His Love(胖哥与女神)

FJNU 1154 Fat Brother And His Love(胖哥与女神) Time Limit: 2000MS   Memory Limit: 257792K [Description] [题目描述] As we know, fat Brother and his goddess is in a same city. The city is consist of N locations and the N locations is connected by M roads. Fat B

FJNU 1153 Fat Brother And XOR(胖哥与异或)

Time Limit: 1000MS   Memory Limit: 257792K [Description] [题目描述] Fat brother had master ACM, recently he began to study the operation of XOR (the operation “^”). He thought of a very interesting question: select arbitrary k positive integers from the

FJNU 1155 Fat Brother’s prediction(胖哥的预言)

FJNU 1155 Fat Brother’s prediction(胖哥的预言) Time Limit: 1000MS   Memory Limit: 257792K [Description] [题目描述] Fat Brother is a famous prophet, One day he get a prediction that disaster will come after X days. He is too nervous that sudden die. Fortunatel

FJNU 1152 Fat Brother And Integer(胖哥与整数)

Time Limit: 1000MS   Memory Limit: 257792K [Description] [题目描述] Fat brother recently studied number theory, him came across a very big problem — minimum does not appear positive integer. Fat brother get n positive integers, he needs to find out the l

FJNU 1157 Fat Brother’s ruozhi magic(胖哥的弱智术)

FJNU 1157 Fat Brother’s ruozhi magic(胖哥的弱智术) Time Limit: 1000MS   Memory Limit: 257792K [Description] [题目描述] Fat Brother is a powerful magician. Both he and his enemy has N soldiers and each soldier has IQ. When two soldier is in PK, the one whose IQ