当前位置:网站首页>CCF adjacent number pairs (Full Score code + problem solving ideas + skill summary) 201409-1
CCF adjacent number pairs (Full Score code + problem solving ideas + skill summary) 201409-1
2022-06-30 14:40:00 【A cute little monkey】
Title Description

Their thinking
- All numbers given in the title are different , So you can sort the numbers first , Then judge whether there is a difference between two adjacent numbers
Code implementation
#include <iostream>
#include <algorithm>
#include <cstring>
using namespace std;
const int N = 1010;
int n;
int a[N];
int main()
{
cin >> n;
for (int i = 0; i < n; i ++)
{
cin >> a[i];
}
sort(a, a + n); // Yes a Array to sort
int res = 0;
for (int i = 1; i < n; i ++)
{
if(a[i] - a[i - 1] == 1) res ++;
}
cout << res;
return 0;
}
Skill summary
- carefully Read the topic information clearly , For example, each number given in the title is different
- Sort the array ,sort(a, a + n)
边栏推荐
- XSS challenge (1-5) more detailed answers
- The JSON data returned from the control layer to JS has a "\" translator. How to remove it
- Go language func function
- Larave8 JWT API expiration custom error return
- [extensive reading of papers] attributes guided facial image completion
- PS dynamic drawing
- Greedy two-dimensional array sorting
- August 24, 2021 deque queue and stack
- Logiciel de récupération de données easyrecovery15 téléchargement
- DB2 SQL Error: SQLCODE=-206, SQLSTATE=42703
猜你喜欢
![[extensive reading of papers] multimodal attribute extraction](/img/ec/546c107ac0d31deded7ca94fdf0e2d.jpg)
[extensive reading of papers] multimodal attribute extraction

Crypto questions

JS to realize simple lottery function

Initial attack and defense world Misc

DiceCTF - knock-knock

Shangpinhui knowledge points of large e-commerce projects

@PathVariable

2021-07-14 mybaitsplus

remote: Support for password authentication was removed on August 13, 2021. Please use a personal ac

2021-05-12
随机推荐
Project management - common English vocabulary I
Why is the resolution of the image generated by PHP GD library 96? How to change it to 72
Detailed explanation of the first three passes of upload Labs
Alipay certificate mode payment interface
Learn about data kinship JSON format design from sqlflow JSON format
Summary of use of laravel DCAT admin
NoViableAltException([email protected][])
Detailed explanation of settimeout() and setinterval()
The first three passes of sqli Labs
Fastcgi CGI shallow understanding
Impersonate server and client using message queuing
Laravel upload error
Go language func function
Is it troublesome for CITIC futures to open an account? Is it safe? How much is the handling charge for opening an account for futures? Can you offer a discount
Add attributes to multimode
[extensive reading of papers] attributes guided facial image completion
Using docker to manage MySQL services under Windows
Pit used by go language array type
Lfi-rce without controllable documents
Upgrade centos7 mysql5.5 to mysql5.7 non RPM in the form of tar package