CCF 201409-1 相邻数对 (水题)
第二行包含所给定的n个整数。
10 2 6 3 7 8
#pragma comment(linker, "/STACK:1024000000,1024000000")
#include <cstdio>
#include <string>
#include <cstdlib>
#include <cmath>
#include <iostream>
#include <cstring>
#include <set>
#include <queue>
#include <algorithm>
#include <vector>
#include <map>
#include <cctype>
#include <cmath>
#include <stack>
#define freopenr freopen("in.txt", "r", stdin)
#define freopenw freopen("out.txt", "w", stdout)
using namespace std; typedef long long LL;
typedef pair<int, int> P;
const int INF = 0x3f3f3f3f;
const double inf = 0x3f3f3f3f3f3f;
const double PI = acos(-1.0);
const double eps = 1e-8;
const int maxn = 100 + 5;
const int mod = 1e9 + 7;
const int dr[] = {0, 1, 0, -1};
const int dc[] = {1, 0, -1, 0};
const char *de[] = {"0000", "0001", "0010", "0011", "0100", "0101", "0110", "0111", "1000", "1001", "1010", "1011", "1100", "1101", "1110", "1111"};
int n, m;
const int mon[] = {0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
const int monn[] = {0, 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
inline int Min(int a, int b){ return a < b ? a : b; }
inline int Max(int a, int b){ return a > b ? a : b; }
inline LL Min(LL a, LL b){ return a < b ? a : b; }
inline LL Max(LL a, LL b){ return a > b ? a : b; }
inline bool is_in(int r, int c){
return r >= 0 && r < n && c >= 0 && c < m;
}
int a[1005]; int main(){
while(scanf("%d", &n) == 1){
for(int i = 0; i < n; ++i) scanf("%d", a+i);
sort(a, a+n);
int ans = 0;
for(int i = 1; i < n; ++i)
if(a[i] - a[i-1] == 1) ++ans;
printf("%d\n", ans);
}
return 0;
}
CCF 201409-1 相邻数对 (水题)的更多相关文章
- ytu 1061: 从三个数中找出最大的数(水题,模板函数练习 + 宏定义练习)
1061: 从三个数中找出最大的数 Time Limit: 1 Sec Memory Limit: 128 MBSubmit: 154 Solved: 124[Submit][Status][We ...
- CCF CSP 201409-1 相邻数对
题目链接:http://118.190.20.162/view.page?gpid=T16 问题描述 试题编号: 201409-1 试题名称: 相邻数对 时间限制: 1.0s 内存限制: 256.0M ...
- 51nod 数数字(水题)
题目链接: 数数字 基准时间限制:1 秒 空间限制:262144 KB 统计一下 aaa ⋯ aaa n个a × b 的结果里面有多少个数字d,a,b,d均为一位数. 样例解释: 3333333333 ...
- CCF系列之相邻数对(201409-1)
试题编号: 201409-1 时间限制: 1.0s 内存限制: 256.0MB 问题描述 给定n个不同的整数,问这些数中有多少对整数,它们的值正好相差1. 输入格式 输入的第一行包含一个整数n,表示给 ...
- 51nod 1717 好数 (水题)
题目: 看起来很复杂,其实就是有多少个素因子就翻转多少次. 然后考虑到只有平方数有奇数个素因子. 一次过,上代码把: #include <iostream> #include <al ...
- 关于一道你们眼中的水题 Windy数 的乱写(数位dp)
啊一道水题有什么好说的 上课听不懂,下课泪两行. 有的人什么套路都会,我.. 只能可怜巴巴的抄代码,然后自己总结,顺(zhu)便(yao)颓博客 1.递推dp的思路做到一半死了,怎么也想不出来如何处理 ...
- CCF 201612-1 最大波动 (水题)
问题描述 小明正在利用股票的波动程度来研究股票.小明拿到了一只股票每天收盘时的价格,他想知道,这只股票连续几天的最大波动值是多少,即在这几天中某天收盘价格与前一天收盘价格之差的绝对值最大是多少. 输入 ...
- <hdu - 3999> The order of a Tree 水题 之 二叉搜索的数的先序输出
这里是杭电hdu上的链接:http://acm.hdu.edu.cn/showproblem.php?pid=3999 Problem Description: As we know,the sha ...
- HDU 6322.Problem D. Euler Function -欧拉函数水题(假的数论题 ̄▽ ̄) (2018 Multi-University Training Contest 3 1004)
6322.Problem D. Euler Function 题意就是找欧拉函数为合数的第n个数是什么. 欧拉函数从1到50打个表,发现规律,然后勇敢的水一下就过了. 官方题解: 代码: //1004 ...
随机推荐
- 洛谷P1258 小车问题
题目描述 甲.乙两人同时从A地出发要尽快同时赶到B地.出发时A地有一辆小车,可是这辆小车除了驾驶员外只能带一人.已知甲.乙两人的步行速度一样,且小于车的速度.问:怎样利用小车才能使两人尽快同时到达. ...
- codeforces Rockethon 2015 C Second price auction [想法]
传送门 C. Second price auction time limit per test 2 seconds memory limit per test 256 megabytes input ...
- msp430入门编程41
msp430中C语言的软件工程--状态机建模
- HDU 6395 分段矩阵快速幂 HDU 6386 建虚点+dij
http://acm.hdu.edu.cn/showproblem.php?pid=6395 Sequence Time Limit: 4000/2000 MS (Java/Others) Me ...
- codevs——1269 匈牙利游戏
1269 匈牙利游戏 2012年CCC加拿大高中生信息学奥赛 时间限制: 1 s 空间限制: 128000 KB 题目等级 : 钻石 Diamond 题解 题目描述 Descript ...
- 转 Linux里设置环境变量的方法(export PATH)
1.动态库路径的设置 Linux下调用动态库和windows不一样.linux 可执行程序是靠配置文件去读取路径的,因此有些时候需要设置路径 具体操作如下export LD_LIBRARY_PATH= ...
- java自动识别用户上传的文本文件编码
原文:http://www.open-open.com/code/view/1420514359234 经常碰到用户上传的部分数据文本文件乱码问题,又不能限制用户的上传的文件编码格式(这样对客户的要求 ...
- 查看MySQL系统变量的命令
用了好长时间mysql,却没有用心记住一些有用的东西,加油! mysql> SHOW VARIABLES; +---------------------------------+-------- ...
- N+6 裁员裁出幸福感的背后
01. 史上最牛逼的数据库公司,Oracle 裁员了. 2019年5月7日,甲骨文召开了面向全中国区的电话会议,亚太区人力资源负责人在会上简要介绍道,公司正进行业务结构调整,导致一部分人要离开岗位,这 ...
- 推荐-zabbix原理篇
推荐-zabbix原理篇(1) 提交 我的留言 加载中 已留言 本文大纲 snmp介绍 监控流程 开源监控工具zabbix zabbix监控功能的实现 支持数据库存储类型 Zabbix架构中的组件 Z ...