当前位置:网站首页>CCF 201409-1: adjacent number pairs (100 points + problem solving ideas)
CCF 201409-1: adjacent number pairs (100 points + problem solving ideas)
2022-06-13 02:06:00 【Python's path to becoming a God】
Problem description :
| Question number : | 201409-1 |
| The title of the test question : | Adjacent number pairs |
| The time limit : | 1.0s |
| Memory limit : | 256.0MB |
| Problem description : | Problem description Given n Different integers , How many pairs of integers are there , Their values are just different 1. Input format The first line of input contains an integer n, Represents the number of given integers . Output format Output an integer , It means that the values are just different 1 The number of pairs of . The sample input 6 Sample output 3 Sample explanation The values are just different 1 The number of pairs includes (2, 3), (6, 7), (7, 8). Evaluate use case size and conventions 1<=n<=1000, The given integer is no more than 10000 Non-negative integer . |
My thoughts :
The difference is 1 The number of , So it's a two-layer loop , The number of outer loops minus the number of inner loops , Then we can get that the value is exactly different 1 The number is right .
Specific code :
#include <iostream>
using namespace std;
int main(int argc, char** argv) {
int len,count=0;
int a[1001];
cin>>len;
for(int i=0;i<len;i++){
cin>>a[i];
}
for(int i=0;i<len;i++){
for(int j=0;j<len;j++){
if(a[i]-a[j]==1){
count++;
}
}
}
cout<<count<<endl;
return 0;
}边栏推荐
- Examples of using the chromium base library
- 如何解决通过new Date()获取时间写出数据库与当前时间相差8小时问题【亲测有效】
- Simple ranging using Arduino and ultrasonic sensors
- Delphi implements adding a column of serial number to the CXGRID list
- What is the path field—— Competitive advertising
- Gome's ambition of "folding up" app
- [the second day of the actual combat of the smart lock project based on stm32f401ret6 in 10 days] light up with the key ----- input and output of GPIO
- 4、 Improvement of warehousing management function
- Devaxpress Chinese description --tcximagelist (enhanced image list control)
- [work with notes] NDK compiles the open source library ffmpeg
猜你喜欢

What is the path field—— Competitive advertising

Record: how to solve the problem of "the system cannot find the specified path" in the picture message uploaded by transferto() of multipartfile class [valid through personal test]

Interruption of 51 single chip microcomputer learning notes (external interruption, timer interruption, interrupt nesting)

Stm32 mpu6050 servo pan tilt support follow

Application circuit and understanding of BAT54C as power supply protection

华为设备配置CE双归属

6、 Implementation of warehouse out management function

How to solve practical problems through audience positioning?

Gome's ambition of "folding up" app

In the third quarter, the revenue and net profit increased "against the trend". What did vatti do right?
随机推荐
Detailed understanding of white noise
Installing Oracle with docker for Mac
STM32 external interrupt Usage Summary
Calculation of accuracy, recall rate, F1 value and accuracy rate of pytorch prediction results (simple implementation)
Functional translation
Examples of using the chromium base library
How to learn C language and share super detailed experience (learning note 1 -- basic data types of C language)
[single chip microcomputer] single timer in front and back platform program framework to realize multi delay tasks
分享三个关于CMDB的小故事
Detailed explanation of maxpooling corresponding to conv1d, conv2d and conv3d machines of tensorflow2
Application and routine of C language typedef struct
The execution results of i+=2 and i++ i++ under synchronized are different
Pyflink implements custom sourcefunction
LabVIEW大型项目开发提高质量的工具
STM32F103 IIC OLED program migration complete engineering code
[the third day of actual combat of smart lock project based on stm32f401ret6 in 10 days] communication foundation and understanding serial port
Learning notes 51 single chip microcomputer keyboard (non coding keyboard and coding keyboard, scanning mode of non coding keyboard, independent keyboard, matrix keyboard)
华为设备配置IP和虚拟专用网混合FRR
Vscode configuration header file -- Take opencv and its own header file as an example
[the 4th day of the 10 day smart lock project based on stm32f401ret6] what is interrupt, interrupt service function, system tick timer