我是靠谱客的博主 昏睡犀牛,最近开发中收集的这篇文章主要介绍A. Spit Problem,觉得挺不错的,现在分享给大家,希望可以做个参考。

概述

A. Spit Problem
time limit per test
2 seconds
memory limit per test
256 megabytes
input
standard input
output
standard output

In a Berland's zoo there is an enclosure with camels. It is known that camels like to spit. Bob watched these interesting animals for the whole day and registered in his notepad where each animal spitted. Now he wants to know if in the zoo there are two camels, which spitted at each other. Help him to solve this task.

The trajectory of a camel's spit is an arc, i.e. if the camel in position x spits d meters right, he can hit only the camel in position x?+?d, if such a camel exists.

Input

The first line contains integer n (1?≤?n?≤?100) — the amount of camels in the zoo. Each of the following n lines contains two integers xiand di (?-?104?≤?xi?≤?104,?1?≤?|di|?≤?2·104) — records in Bob's notepad. xi is a position of the i-th camel, and di is a distance at which the i-th camel spitted. Positive values of di correspond to the spits right, negative values correspond to the spits left. No two camels may stand in the same position.

Output

If there are two camels, which spitted at each other, output YES. Otherwise, output NO.

Sample test(s)
input
2
0 1
1 -1
output
YES
input
3
0 1
1 1
2 -2
output
NO
input
5
2 -10
3 10
0 5
5 -5
10 1
output
YES


注意读题。
/* ***********************************************
Author :
Created Time :2015/6/14 0:27:17
File Name :7.cpp
************************************************ */

#include <iostream>
#include <cstring>
#include <cstdlib>
#include <stdio.h>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <string>
#include <math.h>
#include <stdlib.h>
#include <iomanip>
#include <list>
#include <deque>
#include <stack>
#define ull unsigned long long
#define ll long long
#define mod 90001
#define INF 1<<30
#define maxn 10000+10
#define cle(a) memset(a,0,sizeof(a))

const ull inf = 1LL << 61;
const double eps=1e-5;
using namespace std;

bool cmp(int a,int b){
return a>b;
}
int a[maxn];
int b[maxn];
int main()
{
#ifndef ONLINE_JUDGE
//freopen("in.txt","r",stdin);
#endif
//freopen("out.txt","w",stdout);
int n;
while(cin>>n){
int mark=0;
for(int i=1;i<=n;i++){
cin>>a[i]>>b[i];
}
for(int i=1;i<=n;i++){
for(int j=i+1;j<=n;j++){
if(a[i]+b[i]==a[j]&&a[j]+b[j]==a[i]){
mark=1;break;
}
}
if(mark)break;
}
if(mark)cout<<"YES"<<endl;
else cout<<"NO"<<endl;
}
return 0;
}

最后

以上就是昏睡犀牛为你收集整理的A. Spit Problem的全部内容,希望文章能够帮你解决A. Spit Problem所遇到的程序开发问题。

如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(45)

评论列表共有 0 条评论

立即
投稿
返回
顶部