Numbers

Accepts: 571
Submissions: 1212
Time Limit: 2000/1000 MS (Java/Others)
Memory Limit: 65536/262144 K (Java/Others)
Problem Description

There are n numbers A1,A2....An{A}_{1},{A}_{2}....{A}_{n}A​1​​,A​2​​....A​n​​,your task is to check whether there exists there different positive integers i, j, k (1≤i,j,k≤n1\leq i , j , k \leq n1≤i,j,k≤n) such that Ai−Aj=Ak{A}_{i}-{A}_{j}={A}_{k}A​i​​−A​j​​=A​k​​

Input

There are multiple test cases, no more than 1000 cases. First line of each case contains a single integer n.(3≤n≤100)(3\leq n\leq 100)(3≤n≤100). Next line contains n integers A1,A2....An{A}_{1},{A}_{2}....{A}_{n}A​1​​,A​2​​....A​n​​.(0≤Ai≤1000)(0\leq {A}_{i}\leq 1000)(0≤A​i​​≤1000)

Output

For each case output "YES" in a single line if you find such i, j, k, otherwise output "NO".

Sample Input
3
3 1 2
3
1 0 2
4
1 1 0 2
Sample Output
YES
NO
YES
题解:刚开始用vector写的,发现原来没有count。。。就改成了;
代码:
 #include<cstdio>
#include<iostream>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<set>
using namespace std;
const int INF=0x3f3f3f3f;
const int MAXN=;
int m[MAXN];
int cnt[MAXN];
set<int>st;
int main(){
int n;
while(~scanf("%d",&n)){
st.clear();
memset(cnt,,sizeof(cnt));
for(int i=;i<n;i++){
scanf("%d",m+i);
st.insert(m[i]);
cnt[m[i]]++;
}
int su,flot=;
for(int i=;i<n;i++){
for(int j=i+;j<n;j++){
su=m[i]+m[j];
if(su==m[i]||su==m[j]){
if(cnt[su]==)continue;
}
if(m[i]==m[j]&&m[i]==su){
if(cnt[su]==)continue;
}
if(st.count(su)){
flot=;
break;
}
}
if(flot)break;
}
if(flot)puts("YES");
else puts("NO");
}
return ;
}

Game

Accepts: 0
Submissions: 2320
Time Limit: 2000/1000 MS (Java/Others)
Memory Limit: 131072/131072 K (Java/Others)
Problem Description

XY is playing a game:there are N pillar in a row,which numbered from 1 to n.Each pillar has a jewel.Now XY is standing on the S-th pillar and the exit is in the T-th pillar.XY can leave from the exit only after they get all the jewels.Each time XY can move to adjacent pillar,or he can jump to boundary ( the first pillar or the N-th pillar) by using his superpower.However,he needs to follow a rule:if he left the pillar,he no can not get here anymore.In order to save his power,XY wants to use the minimum number of superpower to pass the game.

Input

There are multiple test cases, no more than 1000 cases. For each case,the line contains three integers:N,S and T.(1≤N≤10000,1≤S,T≤N)(1\leq N\leq10000,1\leq S,T\leq N )(1≤N≤10000,1≤S,T≤N)

Output

The output of each case will be a single integer on a line: the minimum number of using superpower or output -1 if he can't leave.

Sample Input
4 1 4
4 1 3
Sample Output
0
1
题解:各种判断。。。
代码:
 #include<cstdio>
#include<iostream>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<set>
using namespace std;
const int INF=0x3f3f3f3f;
int FABS(int x){
return x>?x:-x;
}
int main(){
int N,S,T;
while(~scanf("%d%d%d",&N,&S,&T)){
if(N==)puts("");
else if(S==T)puts("-1");
else if(S==||S==N){
if(T==||T==N)puts("");
else puts("");
}
else if(T==||T==N){
if(FABS(T-S)==)puts("");
else
puts("");
}
else{
if(FABS(T-S)==)puts("");
else
puts("");
}
}
return ;
}

BestCoder Round #61 (div.2)的更多相关文章

  1. BestCoder Round #61 (div.2) C.Subtrees dfs

    Subtrees   问题描述 一棵有N个节点的完全二叉树,问有多少种子树所包含的节点数量不同. 输入描述 输入有多组数据,不超过1000组. 每组数据输入一行包含一个整数N.(1\leq N\leq ...

  2. BestCoder Round #61 (div.2) B.Game 细节题

    Game   问题描述 XY在玩一个游戏:有N根柱子排成一排,编号为1到N,每个柱子上面有一块宝石,现在XY站在第S根柱子上,出口在第T跟柱子上,XY需要拿到所有宝石后从出口离开.每次XY可以走到相邻 ...

  3. HDU5526/BestCoder Round #61 (div.1)1004 Lie 背包DP

    Lie   问题描述 一个年级总共有N个学生,每个人属于唯一一个班级.现在他们站在一排,同班同学并不一定会站在一起,但每个人都会说一句话:“站在我左边的有Ai个同班同学,右边有Bi个同班同学”.然而并 ...

  4. BestCoder Round #69 (div.2) Baby Ming and Weight lifting(hdu 5610)

    Baby Ming and Weight lifting Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K ( ...

  5. BestCoder Round #68 (div.2) tree(hdu 5606)

    tree Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)Total Submis ...

  6. BestCoder Round #11 (Div. 2) 题解

    HDOJ5054 Alice and Bob Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/O ...

  7. hdu5635 BestCoder Round #74 (div.2)

    LCP Array  Accepts: 131  Submissions: 1352  Time Limit: 4000/2000 MS (Java/Others)  Memory Limit: 13 ...

  8. hdu 5636 搜索 BestCoder Round #74 (div.2)

    Shortest Path  Accepts: 40  Submissions: 610  Time Limit: 4000/2000 MS (Java/Others)  Memory Limit: ...

  9. hdu5634 BestCoder Round #73 (div.1)

    Rikka with Phi  Accepts: 5  Submissions: 66  Time Limit: 16000/8000 MS (Java/Others)  Memory Limit: ...

随机推荐

  1. Unity5UGUI 官方教程学习笔记(一)Canvas

    Canvas Canvas是控制一组UI元素将被渲染 所有的UI元素必须是Canvas下的子物体 一个场景中可以拥有多个Canvas 在创建UI元素时,如果没有Canvas,将会自动创建Canvas ...

  2. Hibernate学习之关系映射(转)

    一.一对多 "一对多"是最普遍的映射关系,简单来讲就如消费者与订单的关系.一对多:从消费者角的度来说一个消费者可以有多个订单,即为一对多.多对一:从订单的角度来说多个订单可以对应一 ...

  3. VS2015如何另存解决方案文件-修改解决方案sln文件的路径

    原文:VS2005如何另存解决方案文件-修改解决方案sln文件的路径 修改解决方案sln文件的路径 方法一:工具→选项→项目和解决方案,可设置项目的默认保存位置.方法二:"解决方案资源管理器 ...

  4. Html 小插件5 百度搜索代码2

    网页添加百度搜索框代码大全 ★ 用法:在下面选择合适的样式,复制代码到网页中相应位置粘贴即可. ★ 样式一(200×30)代码: <iframe id="baiduframe" ...

  5. VC实现卡拉OK字幕叠加

    一. GDI编程基础 字幕叠加,应当是属于图形.图像处理的范畴.在Windows平台上,图形.图像处理的方法当然首选GDI(Graphics Device Interface,图形设备接口).GDI是 ...

  6. mongodb初体验

    最近关注大数据,自然会关注到nosql数据库,其中当然是mongodb. nosql数据库大多是k,v数据库,这也不是新鲜的名词了,berkerly DB已经存在很多年了,现在属于oracle. 具体 ...

  7. 2013第四届蓝桥杯决赛Java高职高专组题目以及解法答案

    2013第四届蓝桥杯决赛Java高职高专组题目以及解法答案 不知不觉离决赛都过去一个月了,一直忙于各种事情,都忘记整理一份试题.当作回忆也好. 1. 标题:好好学习 汤姆跟爷爷来中国旅游.一天,他帮助 ...

  8. jquery简单判断PC端还是移动端

    $(function(){ if (!navigator.userAgent.match(/mobile/i)) { //PC端 }else{ //移动端 } })

  9. Device Mapper Multipath(DM-Multipath)

    Device Mapper Multipath(DM-Multipath)能够将server节点和存储阵列之间的多条I/O链路配置为一个单独的设备.这些I/O链路是由不同的线缆.交换机.控制器组成的S ...

  10. 扩大或缩小undo表空间

    ***********************************************声明*************************************************** ...