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. qt检测网络连接状态【只能检测和路由器的连接,不能测试到外网的连接】

    #include <QCoreApplication>#include <QDebug>#include <QTextStream>#include <QDi ...

  2. html mysql special character

    function html_encode(str) { var s = ""; if (str.length == 0) return ""; s = str. ...

  3. R与数据分析旧笔记(二)随机抽样的一个综合例子

    题目:模拟产生统计专业同学的名单(学号区分),记录数学分析.线性代数.概率统计三科成绩,然后进行一些统计分析 > num=seq(10378001,10378100) > num [1] ...

  4. 美化 input type=file控件

    大家都知道input的type=file控件默认样式是不能修改的 可以通过一个小技巧处理下 html: <a href="javascript:;" class=" ...

  5. Streams Studio配置Build options

    Defining build options You can change the build options of the internal builder for building an SPL ...

  6. VC6神迹外挂的DIY

    2014年09月05日 ⁄ 综合 ⁄ 共 8724字 ⁄ 字号 小 中 大 ⁄ 评论关闭 (一)外挂一般都能在游戏的界面中按一个热键(比如F12,HOME等),就可以呼出外挂的窗口,然后在里面进行外挂 ...

  7. [Laravel 5] 表单验证 Form Requests and Controller Validation

    本文 转载自:http://blog.hsin.tw/2015/laravel-5-note09-form-requests-and-controller-validation/ 文章解答了我的困惑非 ...

  8. aliyun opts 集锦

    <一,>,aliyun 使用数据盘(aliyun新增数据盘使用,创建vg,aliyun 镜像系统本身未使用lvm-vg-lv) 1.1直接挂载文件系统 较易,不做分析 http://hel ...

  9. python闭包以及装饰器

    通俗的定义:如果在一个内部函数里,对在外部作用域(但不是在全局作用域)的变量进行引用,那么内部函数就被认为是闭包(closure).它只不过是个“内层”的函数,由一个名字(变量)来指代,而这个名字(变 ...

  10. linux线程之pthread_join

    pthread_join使一个线程等待另一个线程结束. 代码中如果没有pthread_join:主线程会很快结束从而使整个进程结束,从而使创建的线程没有机会开始执行就结束了.加入pthread_joi ...