HDU 3833 YY's new problem ()
YY's new problem
Time Limit: 12000/4000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others)
Total Submission(s): 5422 Accepted Submission(s):
1522
whether there exists such three elements P[i1], P[i2],
P[i3] that
P[i1]-P[i2]=P[i2]-P[i3],
1<=i1<i2<i3<=N.
test cases.
Each test case comes two lines, the former one is N,
3<=N<=10000, the latter is a permutation of 1 to N.
i1, i2, i3 can be found, else 'N'.
3
1 3 2
4
3 2 4 1
Y
#include <iostream>
#include <stdio.h>
using namespace std;
int main()
{
int i,j,n,t,a[],b[],flag,s;
scanf("%d",&t);
while(t--)
{
scanf("%d",&n);
flag=;
for(i=;i<n;i++)
{
scanf("%d",&a[i]);
b[a[i]]=i;
}
for(i=;i<n;i++)
for(j=i+;j<n;j++)
{
s=a[i]+a[j];
if(s%)
continue;
if(b[s/]>i&&b[s/]<j)
{
flag=;
break;
}
if(flag)
break;
}
if(flag)
printf("Y\n");
else
printf("N\n");
}
return ;
}
HDU 3833 YY's new problem ()的更多相关文章
- HDU 3833 YY's new problem(换种思路的模拟,防超时)
题目链接 用p[a]保存的是输入的a在第p[a]个, 然后根据差值查找. #include<stdio.h> #include<string.h> int main() { ...
- G - YY's new problem(HUSH算法,目前还不懂什么是HUSH算法)
Time Limit:4000MS Memory Limit:65536KB 64bit IO Format:%I64d & %I64u Submit Status Pra ...
- HDU 4974 A simple water problem(贪心)
HDU 4974 A simple water problem pid=4974" target="_blank" style="">题目链接 ...
- HDU 5572 An Easy Physics Problem (计算几何+对称点模板)
HDU 5572 An Easy Physics Problem (计算几何) 题目链接http://acm.hdu.edu.cn/showproblem.php?pid=5572 Descripti ...
- HDU 3861 The King’s Problem(强连通+二分图最小路径覆盖)
HDU 3861 The King's Problem 题目链接 题意:给定一个有向图,求最少划分成几个部分满足以下条件 互相可达的点必须分到一个集合 一个对点(u, v)必须至少有u可达v或者v可达 ...
- hdu 5349 MZL's simple problem
题目连接 http://acm.hdu.edu.cn/showproblem.php?pid=5349 MZL's simple problem Description A simple proble ...
- HDU 5924 Mr. Frog’s Problem 【模拟】 (2016CCPC东北地区大学生程序设计竞赛)
Mr. Frog's Problem Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Other ...
- HDU 4978 A simple probability problem
A simple probability problem Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/65536 K ( ...
- 【HDU 5572 An Easy Physics Problem】计算几何基础
2015上海区域赛现场赛第5题. 题目连接:http://acm.hdu.edu.cn/showproblem.php?pid=5572 题意:在平面上,已知圆(O, R),点B.A(均在圆外),向量 ...
随机推荐
- 【poj1201】 Intervals
http://poj.org/problem?id=1201 (题目链接) 题意 给出n个区间${[ai,bi]}$,要求选出尽可能少的数,使得每个区间i中至少存在${c[i]}$个数. Soluti ...
- Codeforces 548B Mike and Fun
传送门 B. Mike and Fun time limit per test 2 seconds memory limit per test 256 megabytes input standard ...
- iOS 知识点梳理
OC的理解与特性 OC作为一门面向对象的语言,自然具有面向对象的语言特性:封装.继承.多态.它既具有静态语言的特性(如C++),又有动态语言的效率(动态绑定.动态加载等).总体来讲,OC确实是一门不错 ...
- POJ1995(整数快速幂)
http://poj.org/problem?id=1995 题意:求(A1^B1 + A2^B2 + .....Ah^Bh)%M 直接快速幂,以前对快速幂了解不深刻,今天重新学了一遍so easy ...
- sql-server数据库中利用触发器实现表与表之间的级联删除
create trigger Delete_Student --创建一个触发器 on student instead of delete as declare @sno varchar() selec ...
- 在ECSHOP后台左侧导航中增加新菜单
在ECSHOP后台左侧导航中增加新菜单 ECSHOP教程/ ecshop教程网(www.ecshop119.com) 2011-11-08 有个别高级用户(懂PHP的),提到这样的问题: 在后台管 ...
- 反射型xss绕过IE xss filter
反射xss利用方法,绕过IE XSS Filter 假设 1.php页面代码如下: echo $_GET['str']; 使用IE浏览器访问该页面 1.php?str=<xss code> ...
- JavaScript 技巧总结
日期1. 日期时间戳 +new Date() = new Date().getTime() 数组1. 类数组转数组 var arr = Array.prototype.slice.call(argum ...
- C语言绘制余弦函数图象
#include"stdio.h" #include"math.h" void main() { double y; int x,m; for(y=1;y> ...
- detours安装和使用
http://blog.csdn.net/evi10r/article/details/6659354 http://blog.csdn.net/donglinshengan/article/deta ...