当前位置:网站首页>Codeforces round 580 (Div. 2) c- almost equal [Law]
Codeforces round 580 (Div. 2) c- almost equal [Law]
2022-07-24 19:34:00 【Cold instant noodles】
Codeforces Round #580 (Div. 2) C- Almost Equal【 law 】
subject :
http://codeforces.com/contest/1206/problem/C
General meaning :
Input n, Put the numbers 1~2n In a circle , Make any two “ continuity n Sum of numbers ” The difference between them is no more than 1.
Ideas :
Guess what n = even numbers There is no solution at all , Direct output NO.
n = Odd number When ,1 and 2 The location of this is certain ,1 Back up n-1 A digital , The first even numbers Yes The previous number +3, The first Odd number Yes The previous number +1.2 Back up n-1 A digital , The first even numbers Yes The previous number +1, The first Odd number Yes The previous number +3.
Code :
#include<iostream>
#include<string.h>
#include<algorithm>
#include<cstdio>
#include<cstdlib>
using namespace std;
int main() {
int n;
scanf("%d",&n);
if(n % 2 == 0) {
printf("NO\n");
}
else {
printf("YES\n");
printf("1");
int num = 1;
for(int i = 0; i < n-1; i++) {
if(i % 2 == 0) {
printf(" %d",num+3);
num += 3;
}
else {
printf(" %d",num+1);
num += 1;
}
}
printf(" 2");
num = 2;
for(int i = 0; i < n-1; i++) {
if(i % 2 == 0) {
printf(" %d",num+1);
num += 1;
}
else {
printf(" %d",num+3);
num += 3;
}
}
printf("\n");
}
return 0;
}
边栏推荐
- Interface component devaxpress asp Net v22.1 - new office 365 dark theme
- Machine learning_ Data processing and model evaluation
- Reading notes: you only look once:unified, real time object detection
- Compressed string
- Tencent Browser service TBS usage
- Flink Window&Time 原理
- Literature reading: gopose 3D human pose estimation using WiFi
- [understanding of opportunity-48]: Guiguzi - Chapter 7 - collect information in advance, make predictions and implementation plans in advance
- Chapter 4 compound type
- Machine learning_ Softmax function (multi classification problem)
猜你喜欢

Hucang integrated release of full data value, sequoiadb V5.2 online conference heavy attack

Analysis of the basic concept of digital warehouse

Original reverse compensation and size end
![[JVM learning 04] JMM memory model](/img/8c/0f76be122556301a5af140e34b55f4.png)
[JVM learning 04] JMM memory model

How to use the interface control telerik UI for WinForms development step progress bar?

【JVM学习03】类加载与字节码技术

Literature reading: gopose 3D human pose estimation using WiFi

拿捏C指针

文献阅读:GoPose 3D Human Pose Estimation Using WiFi

PostgreSQL Elementary / intermediate / advanced certification examination (7.16) passed the candidates' publicity
随机推荐
Siyuan notes V2.1.2 synchronization problem
纯C实现----------尼科彻斯定理
Nezha monitoring - server status monitoring, SSL certificate change expiration, Ping monitoring and scheduled task reminder
[JVM learning 04] JMM memory model
Get module handle / base address
Jedi survive and eat chicken F12 screenshot save path reference
Thread theory knowledge
Cmake series tutorial 1- initial cmake
JDBC batch inserts 100000 /1million pieces of data
C language implementation of raii
Virbox compiler, which supports source code encryption of the whole platform and architecture
asp. Net core, C # summary about path
Sword finger offer 48. the longest substring without repeated characters
Timed task framework
Why are there loopholes in the website to be repaired
Know typescript
Ebpf verifier
从服务器批量下载文件到本地
Equals() method of object class
On July 31, 2022, the dama-cdga/cdgp data governance certification class was opened!