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(均在圆外),向量 ...
随机推荐
- SpringMVC数据库链接池,以及其他相关配置
1.applicationContext.xml <?xml version="1.0" encoding="UTF-8"?> <beans ...
- linux内核数据结构学习总结
目录 . 进程相关数据结构 ) struct task_struct ) struct cred ) struct pid_link ) struct pid ) struct signal_stru ...
- SPOJ Pouring Water
传送门 POUR1 - Pouring water #gcd #recursion Given two vessels, one of which can accommodate a litres o ...
- POJ1745Divisibility(01背包思想)
Divisibility Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 11151 Accepted: 3993 Des ...
- jquery------显示加载的js时出现中文乱码解决方法
方法: 把my.js文件复制出来,用记事本打开,再另存为的时候设置编码格式为utf-8即可
- electron加载jquery报错问题
<!-- Insert this line above script imports --> <script>if (typeof module === 'object') { ...
- CentOS 6.4 32位系统 LAMP(Apache+MySQL+PHP)安装步骤
先来解释一下,什么是 LAMP.正如标题所言,LAMP 实际上就是 Linux.Apache.MySQL.PHP 四个名称的缩写,当然最后一个 “P” 还有其他说法是 Perl 或者 Python.不 ...
- zabbix 汉化
zabbix2.x的版本自带汉化,3.x的版本也可以通过修改配置文件强制使用自带的汉化,但是不管哪种,翻译的精准度令人费解:偶然发现一个专门翻译zabbix的网站https://www.zabbix. ...
- Zabbix 监控 Nginx 状态
简介: 如何使用 Zabbix 监控 Nginx 状态 ? 1.获取 Nginx 状态( HTTP Stub Status ) shell > /usr/local/nginx/sbin/ngi ...
- 工具类HttpServerUtility
在ASP.NET服务器上提供一个辅助的工具类HttpServerUtility,该类提供了一些处理请求的辅助方法. MapPath:计算网站中虚拟路径所对应的物理文件路径. HtmlEncode:将H ...