CodeForces - 669D Little Artem and Dance 想法题 多余操作
http://codeforces.com/problemset/problem/669/D
题意:n个数1~N围成一个圈。q个操作包括操作1:输入x, 所有数右移x。操作2:1,2位置上的数(swap(a[1], a[2])交换;3,4交换。。。。
题解:观察,发现所有奇数行为都是一样的,偶数同理,(对于操作1 两者相同,对于操作2 奇数位++,偶数位上--;
模拟1,2,即可,然后依次输出其它数字即可。(看清
ac代码:
#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<string.h>
#include<iostream>
using namespace std;
const int maxn = 1e6 + ;
const int mod= 1e9 + ;
int a[maxn], x[maxn];
int main(){
int n, q;
cin >> n >> q;
int A=, B=;
for (int i = ; i <= q; i++) {
int x;
scanf("%d", &x); if(x==){
scanf("%d", &x);
A += x;
B += x;
}
else {
if (A & )A++, B--;
else A--, B++;
}
A %= n;
B %= n;
}
while (A <= )A += n;
while (B <= )B += n;
for (int i = ; i < n; i+=) {
a[A] = i; a[B] = i + ;
A+=; B+=;
if (A > n)A -= n;
if (B > n)B -= n;
}
for (int i = ; i <= n; i++)cout << a[i] << ' ';
}
CodeForces - 669D Little Artem and Dance 想法题 多余操作的更多相关文章
- Codeforces 669D Little Artem and Dance (胡搞 + 脑洞)
		
题目链接: Codeforces 669D Little Artem and Dance 题目描述: 给一个从1到n的连续序列,有两种操作: 1:序列整体向后移动x个位置, 2:序列中相邻的奇偶位置互 ...
 - CodeForces 669D Little Artem and Dance
		
模拟. 每个奇数走的步长都是一样的,每个偶数走的步长也是一样的. 记$num1$表示奇数走的步数,$num2$表示偶数走的步数.每次操作更新一下$num1$,$num2$.最后输出. #pragma ...
 - CodeForces 111B - Petya and Divisors 统计..想法题
		
找每个数的约数(暴力就够了...1~x^0.5)....看这约数的倍数最后是哪个数...若距离大于了y..统计++...然后将这个约数的最后倍数赋值为当前位置...好叼的想法题.... Program ...
 - CodeForces 668B Little Artem and Dance
		
B. Little Artem and Dance time limit per test 2 second memory limit per test 256 megabytes input sta ...
 - codeforces 669D D. Little Artem and Dance(乱搞题)
		
题目链接: D. Little Artem and Dance time limit per test 2 seconds memory limit per test 256 megabytes in ...
 - Codeforces Round #348 (VK Cup 2016 Round 2, Div. 2 Edition) D. Little Artem and Dance 模拟
		
D. Little Artem and Dance 题目连接: http://www.codeforces.com/contest/669/problem/D Description Little A ...
 - D. Little Artem and Dance
		
题目链接:http://codeforces.com/problemset/problem/669/D D. Little Artem and Dance time limit per test 2 ...
 - D. Little Artem and Dance(带环模拟 + 规律)
		
D. Little Artem and Dance Little Artem is fond of dancing. Most of all dances Artem likes rueda - Cu ...
 - HDU 4972 Bisharp and Charizard  想法题
		
Bisharp and Charizard Time Limit: 1 Sec Memory Limit: 256 MB Description Dragon is watching NBA. He ...
 
随机推荐
- Android ViewDragHelper全然解析 自己定义ViewGroup神器
			
转载请标明出处: http://blog.csdn.net/lmj623565791/article/details/46858663. 本文出自:[张鸿洋的博客] 一.概述 在自己定义ViewGro ...
 - eclipse中设置文件的编码格式为utf-8
			
1.可以在 eclipse 中配置 workspace 项下 text file encoding 属性的值来决定此工作区间下所有的 eclipse 项目的文档的编码属性. Window-->P ...
 - webstrom 2017 安装及配置
			
下载安装:http://www.jetbrains.com/webstorm/ 激活:安装完成后,在打开的 License Activation 窗口中选择 License server. 在输入框输 ...
 - PostgreSQL恢复误删数据
			
在Oracle中:删除表或者误删表记录:有个闪回特性,不需要停机操作,可以完美找回记录.当然也有一些其他的恢复工具:例如odu工具,gdul工具.都可以找回数据.而PostgreSQL目前没有闪回特性 ...
 - Linux应急响应(三):挖矿病毒
			
0x00 前言  随着虚拟货币的疯狂炒作,利用挖矿脚本来实现流量变现,使得挖矿病毒成为不法分子利用最为频繁的攻击方式.新的挖矿攻击展现出了类似蠕虫的行为,并结合了高级攻击技术,以增加对目标服务器感染 ...
 - mysql5.6.34-debug Source distribution在树莓派下编译的几个错误
			
raspberrypi下编译mysql5.6 debug版源码. 1. 启动错误 和mysqld相关的文件及文件夹权限必须设置为mysql用户可读可写可执行,特别是/var/run/mysqld/目录 ...
 - Java的I/O操作
			
一.概述 Java的IO支持通过java.io包下的类和接口来完成,在java.io包下主要有包括输入.输出两种IO流,每种输入输出流又可分为字节流和字符流两大类.从JDK1.4以后,Java在jav ...
 - 【大数据系列】节点的退役和服役[datanode,yarn]
			
一.datanode添加新节点 1 在dfs.include文件中包含新节点名称,该文件在名称节点的本地目录下 [白名单] [s201:/soft/hadoop/etc/hadoop/dfs.incl ...
 - css笔记 - 张鑫旭css课程笔记之 overflow 篇
			
overflow基本属性值 visible(默认值):超出依然显示 hidden :超出隐藏 scroll :超出,滚动显示.子元素不超出也会有滚动条的那条轨道. auto:如果超出,滚动显示.如果不 ...
 - Android org.apache.http.*找不到
			
https://blog.csdn.net/u012005313/article/details/51499892 直接把 org.apache.http.legacy.jar 报拷贝出来,放到Ecl ...