很简单的一个题;

只需要将他们排一下序,然后判断一下就可以了!

代码:

 #include<cstdio>
#include<algorithm>
#define maxn 100005
using namespace std; int n,x;
int a[maxn][],cot;
struct node
{
int v,id;
bool operator<(node const &t)const
{
if(v==t.v)return id<t.id;
return v<t.v;
}
} no[maxn]; int main()
{
scanf("%d",&n);
for(int i=; i<=n; i++)
{
scanf("%d",&x);
no[i].v=x;
no[i].id=i;
}
sort(no+,no+n+);
for(int i=; i<=n;)
{
int t=no[i].v;
if(no[i+].v!=t)
{
a[cot][]=no[i].v;
a[cot][]=;
cot++;
i++;
}
else
{
int d=no[i+].id-no[i].id;
while()
{
i++;
if(no[i+].v!=t)
{
a[cot][]=t;
a[cot][]=d;
cot++;
i++;
break;
}
if(no[i+].id-no[i].id!=d)
{
while()
{
i++;
if(no[i+].v!=no[i].v)
{
i++;
break;
}
}
break;
}
}
}
}
printf("%d\n",cot);
for(int i=;i<cot;i++)
printf("%d %d\n",a[i][],a[i][]);
return ;
}

Codeforces Round #204 (Div. 2): B的更多相关文章

  1. CF&&CC百套计划3 Codeforces Round #204 (Div. 1) A. Jeff and Rounding

    http://codeforces.com/problemset/problem/351/A 题意: 2*n个数,选n个数上取整,n个数下取整 最小化 abs(取整之后数的和-原来数的和) 先使所有的 ...

  2. Codeforces Round #204 (Div. 2)->C. Jeff and Rounding

    C. Jeff and Rounding time limit per test 1 second memory limit per test 256 megabytes input standard ...

  3. CF&&CC百套计划3 Codeforces Round #204 (Div. 1) E. Jeff and Permutation

    http://codeforces.com/contest/351/problem/E 题意: 给出一些数,可以改变任意数的正负,使序列的逆序对数量最少 因为可以任意加负号,所以可以先把所有数看作正数 ...

  4. CF&&CC百套计划3 Codeforces Round #204 (Div. 1) B. Jeff and Furik

    http://codeforces.com/contest/351/problem/B 题意: 给出一个n的排列 第一个人任选两个相邻数交换位置 第二个人有一半的概率交换相邻的第一个数>第二个数 ...

  5. CF&&CC百套计划3 Codeforces Round #204 (Div. 1) D. Jeff and Removing Periods

    http://codeforces.com/problemset/problem/351/D 题意: n个数的一个序列,m个操作 给出操作区间[l,r], 首先可以删除下标为等差数列且数值相等的一些数 ...

  6. Codeforces Round #204 (Div. 2) A.Jeff and Digits

    因为数字只含有5或0,如果要被90整除的话必须含有0,否则输出-1 如果含有0的话,就只需考虑组合的数字之和是9的倍数,只需要看最大的5的个数能否被9整数 #include <iostream& ...

  7. Codeforces Round #204 (Div. 2)->D. Jeff and Furik

    D. Jeff and Furik time limit per test 1 second memory limit per test 256 megabytes input standard in ...

  8. Codeforces Round #204 (Div. 2)->B. Jeff and Periods

    B. Jeff and Periods time limit per test 1 second memory limit per test 256 megabytes input standard ...

  9. Codeforces Round #204 (Div. 2) C

    写了一记忆化 TLE了  把double换成long long就过了 double 这么耗时间啊 #include <iostream> #include<cstdio> #i ...

随机推荐

  1. 谷歌google搜索打不开、谷歌gmail邮箱及相关服务无法登录的解决的方法

    歌打不开 google打不开,与中国大陆封杀有关,可是主要是由于近期googleserver在全球范围内又一次进行了布局调整. 解决的方法是仅仅要改动用户本地计算机hosts文件就能够了. 一.Win ...

  2. linux shell pushd popd dirs命令

    1.dirs 1)功能显示当前目录栈中的所有记录(不带参数的dirs命令显示当前目录栈中的记录) 2)语法(1)格式:dirs  [-clpv]  [+n]  [-n](2)选项-c    删除目录栈 ...

  3. linux中的帮助命令 分类: linux 学习笔记 ubuntu 2015-07-05 19:07 31人阅读 评论(0) 收藏

    说实话,到目前为止我还是不太习惯使用linux自带的帮助文档,遇到问题都是去查我自己下载的chm格式的命令大全,不过这些帮助命令我们还是有必要了解的. 1.man [要查看的命令名称] 例如想要查看l ...

  4. Linux下Tomcat安装、配置

    /etc/profile./etc/profile.d和.bash_profile区别 /etc/profile和/etc/profile.d区别 .bash_profile 是存放用户的全局变量 / ...

  5. datatables常见报错

    Uncaught TypeError: Cannot read property 'style' of undefined 分析:列表配置 columnDefs 列数不匹配 来自为知笔记(Wiz)

  6. C# 日期之间的间隔

    今天工作中,突然遇到要计算两个时间之间的天数,最后把自己的方法记录下来,其实挺简单的: DateTime dt1=Convert.ToDateTime("2014/8/1 23:53:31& ...

  7. C# 文件粉碎

    >文件粉碎的流程 填充文件 更改最后使用/创建时间 更改名称 将大小改为 0 kb 删除 using System; using System.Collections.Generic; usin ...

  8. MongoDB 3.0安全权限访问控制(Windows版)

    MongoDB 3.0安全权限访问控制(Windows版) 1.首先,不使用 –auth 参数,启动 mongoDB: mongod --dbpath "d:\mongodb\data\db ...

  9. struts2-ognl 访问静态方法

    在内网基本上还真没看到有哥们发现这个问题, 在google上有的哥们说 这是 v 2.3.20的一个bug, 有的人说在该版本中已经不建议通过ognl方式访问静态方法了. 对于这两种说法, 我比较赞同 ...

  10. IIS防止同一IP大量非法访问

    在服务器设置访问规则,屏蔽恶意ip就可以了