当前位置:网站首页>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;
}
边栏推荐
- How to encrypt your own program with dongle
- Pyhanlp installation tutorial
- [untitled]
- 纯C实现----------尼科彻斯定理
- Common methods of string class
- Getaverse,走向Web3的远方桥梁
- How to select software dongle
- Pay close attention! List of the latest agenda of 2022 open atom open source Summit
- Meshlab & PCL ISS key points
- C language implementation of raii
猜你喜欢

On July 31, 2022, the dama-cdga/cdgp data governance certification class was opened!

In the spring of domestic databases

Meshlab & PCL ISS key points

Pam4 popular science

How to export map files tutorial

Techempower web framework performance test 21st round results release --asp Net core continue to move forward

Create a life cycle aware MVP architecture

Literature reading: gopose 3D human pose estimation using WiFi

MySQL1

Original reverse compensation and size end
随机推荐
Install SSL Certificate in Litespeed web server
MySQL index principle and query optimization "suggestions collection"
asp. Net core, C # summary about path
Look at the interface control devaxpress WinForms - how to customize auxiliary function properties (Part 2)
[understanding of opportunity-48]: Guiguzi - Chapter 7 - collect information in advance, make predictions and implementation plans in advance
Nezha monitoring - server status monitoring, SSL certificate change expiration, Ping monitoring and scheduled task reminder
Interface component devaxpress asp Net v22.1 - new office 365 dark theme
Mysql database, de duplication, connection
Jedi survive and eat chicken F12 screenshot save path reference
Getaverse, a distant bridge to Web3
This visual analysis library makes it easy for you to play with data science!
【德味】安全:如何为行人提供更多保护
Clion configuring WSL tool chain
Day 10 (inheritance, rewriting and use of super)
Sword finger offer 47. the maximum value of gifts
MySQL version 5.7.9 SQL_ mode=only_ full_ group_ By question
文献阅读:GoPose 3D Human Pose Estimation Using WiFi
Ebpf verifier
DDR SDRAM board design guide
Sword finger offer 48. the longest substring without repeated characters