Codeforces 669D Little Artem and Dance (胡搞 + 脑洞)
题目链接:
Codeforces 669D Little Artem and Dance
题目描述:
给一个从1到n的连续序列,有两种操作:
1:序列整体向后移动x个位置,
2:序列中相邻的奇偶位置互换。
问:q次操作后,输出改变后的序列?
解题思路:
刚开始只看了第一组样例,发现相邻的奇偶位一直在一起,于是乎就开始writing code,写完后发现并不是正解!!!!就去推了一下第三个样例,总是这组实例通过,那组实例卡死,,,,,,,最后终于成功的Mengbility。今天突然想起来,其实整体向后移动,奇偶位置交换,并不会影响奇数的顺序和偶数的顺序。所以只需要记录1的位置和2的位置即可。
#include <iostream>
#include <algorithm>
#include <stdio.h>
#include <cstring>
#include <queue>
using namespace std; const int maxn = ;
int ans[maxn]; int main ()
{
int n, q; while (scanf ("%d %d", &n, &q) != EOF)
{
int wz1 = , wz2 = ; while (q --)
{
int op, x; scanf ("%d", &op); if (op == )
{
scanf ("%d", &x);
wz1 = ((wz1 + x) % n + n) % n;
wz2 = ((wz2 + x) % n + n) % n;
}
else
{
int a = wz1 % ? - : ;
int b = wz2 % ? - : ; wz1 = ((wz1 + a) % n + n) % n;
wz2 = ((wz2 + b) % n + n) % n;
}
} for (int i=; i<n; i+=)
{
ans[(i+wz1)%n] = i + ;
ans[(i+wz2)%n] = i + ;
}
for (int i=; i<n; i++)
printf ("%d%c", ans[i], i==n-?'\n':' ');
}
return ;
}
Codeforces 669D Little Artem and Dance (胡搞 + 脑洞)的更多相关文章
- CodeForces - 669D  Little Artem and Dance   想法题 多余操作
		
http://codeforces.com/problemset/problem/669/D 题意:n个数1~N围成一个圈.q个操作包括操作1:输入x, 所有数右移x.操作2:1,2位置上的数(swa ...
 - CodeForces 669D Little Artem and Dance
		
模拟. 每个奇数走的步长都是一样的,每个偶数走的步长也是一样的. 记$num1$表示奇数走的步数,$num2$表示偶数走的步数.每次操作更新一下$num1$,$num2$.最后输出. #pragma ...
 - 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 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 394D Physical Education and Buns 胡搞
		
题目链接:点击打开链接 题意:给定n个数的序列(能够排序) 操作一次能够使得某个数++或--. 问最少操作几次使得序列变成一个等差序列 输出: 第一行输出最少操作的次数 第二行输出等差数列里的最小项 ...
 - 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 ...
 - [LeetCode]Integer Break(Dp或胡搞或推公式)
		
343. Integer Break Given a positive integer n, break it into the sum of at least two positive intege ...
 - HDU 4690 EBCDIC (2013多校 1005题   胡搞题)
		
EBCDIC Time Limit: 2000/2000 MS (Java/Others) Memory Limit: 102400/102400 K (Java/Others)Total Su ...
 
随机推荐
- java中使用反射获取pojo(实体)类的全部字段值
			
说起反射.不得不说它实在是太强大了,通过反射就能够轻轻松松拿到各种东东,假设你想在项目中解除对某个类的依赖,能够考虑用反射. 今天跟大家分享的是通过java中的反射,获取pojo类的全部字段值. 为什 ...
 - SDOI2016R1(不是解题报告)
			
话说洗澡的时候想了一堆要说的,坐到电脑前反而不知所措了-- 序章 听学长说他们都是省选一周前才停的课.然而我们这届--自聪哥韩大他们在省选两周前悄悄跑路后(据说班主任非常支持),信息小组内部一呼百应, ...
 - UI类继承关系图
 - hadoop reduce 阶段遍历 Iterable 的 2 个“坑”
			
01 package com.test; 02 03 import java.util.ArrayList; 04 import java.util.Iterator; 05 import jav ...
 - C/C++实现删除字符串的首尾空格
			
StdStringTrimTest.cpp #include <iostream> int main() { std::string str(" 字符串 String " ...
 - 使用URL dispatcher的范例
			
在上面的一篇文章中,我们介绍了怎样使用URL disptacher.在这篇文章中,我们来通过一个范例更进一步来了解怎样实现它. 1)创建一个具有URL dispatcher的应用 我们首先打开我们的S ...
 - mysql 发生系统错误1067
			
一般是由配置文件错误语法不正确引起的,如my.ini本人在mysql mysql-5.6.29-winx64 配置过程中遇到“发生系统错误1067”主要由于下面两个目录写的格式不正确引起的正确写法如下 ...
 - fminunc
			
options = optimset('GradObj', 'on', 'MaxIter', 400); % Run fminunc to obtain the optimal theta% This ...
 - codeforces   399B. Red and Blue Balls   解题报告
			
题目链接:http://codeforces.com/problemset/problem/399/B 题目意思:给出 n 个只由 R 和 B 组成的字符串(由上到下排列,相当于栈),问最多可以操作多 ...
 - html5--6-52 动画效果-过渡
			
html5--6-52 动画效果-过渡 实例 @charset="UTF-8"; div{ width: 300px; height: 150px; margin: 30px; f ...