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 想法题 多余操作的更多相关文章

  1. Codeforces 669D Little Artem and Dance (胡搞 + 脑洞)

    题目链接: Codeforces 669D Little Artem and Dance 题目描述: 给一个从1到n的连续序列,有两种操作: 1:序列整体向后移动x个位置, 2:序列中相邻的奇偶位置互 ...

  2. CodeForces 669D Little Artem and Dance

    模拟. 每个奇数走的步长都是一样的,每个偶数走的步长也是一样的. 记$num1$表示奇数走的步数,$num2$表示偶数走的步数.每次操作更新一下$num1$,$num2$.最后输出. #pragma ...

  3. CodeForces 111B - Petya and Divisors 统计..想法题

    找每个数的约数(暴力就够了...1~x^0.5)....看这约数的倍数最后是哪个数...若距离大于了y..统计++...然后将这个约数的最后倍数赋值为当前位置...好叼的想法题.... Program ...

  4. 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 ...

  5. 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 ...

  6. 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 ...

  7. D. Little Artem and Dance

    题目链接:http://codeforces.com/problemset/problem/669/D D. Little Artem and Dance time limit per test 2 ...

  8. D. Little Artem and Dance(带环模拟 + 规律)

    D. Little Artem and Dance Little Artem is fond of dancing. Most of all dances Artem likes rueda - Cu ...

  9. HDU 4972 Bisharp and Charizard 想法题

    Bisharp and Charizard Time Limit: 1 Sec  Memory Limit: 256 MB Description Dragon is watching NBA. He ...

随机推荐

  1. ios开发之--CGRectGetXxx方法图解 和代码NSLog输出值

    - (void)test { CGRect rect = CGRectMake(, , , ); // 最小Y坐标,即矩形的顶部top y坐标: minY = rect.y = 20.000000 N ...

  2. iOS 在已有项目添加CoreData

    本文转载至 http://cnbin.github.io/blog/2016/03/11/ios-zai-yi-you-xiang-mu-tian-jia-coredata/ 如果是新项目很好说,新建 ...

  3. 《计算机图形学》2.1.4 彩色CRT监视器

    CRT监视器利用能发射不同颜色光的荧光层的组合来显示彩色图形.不同荧光层的发射光组合起来,可以生成一种按其比例而定的可见颜色. 显示彩色图形的一种方法是在屏幕上涂上多层不同的荧光粉.发射颜色由电子束在 ...

  4. Java接口回调机制

    一.前言 最近在看android Fragment与Activity进行数据传递的部分,看到了接口回调的内容,今天来总结一下. 二.回调的含义和用途 1.什么是回调? 一般来说,模块之间都存在一定的调 ...

  5. 原创:Eclipse安装Eclipse Color Themes插件后,编辑器背景颜色被改变

    如题,卸载Eclipse Color Themes插件后,背景颜色还是白色,蛋疼,修改.metadata\.plugins\org.eclipse.core.runtime\.settings中的or ...

  6. myeclipse使用小技巧

    1 如何关掉maven自动更新,去掉前面的勾 2 myeclipse中如何设置不校验js

  7. 【Linux】使用 telnet 提示 Escape character is '^]'的意义

    在linux/unix下使用telnet hostname port连接上主机后会提示Escape character is '^]' 这个提示的意思是按Ctrl + ] 会呼出telnet的命令行, ...

  8. Android 手机震动

    1.添加震动权限 <uses-permission android:name="android.permission.VIBRATE"/> 2.获取震动服务 Vibra ...

  9. laravel + php cgi + nginx在windows平台下的配置

    1.d:\xampp\php\php-cgi.exe -b 127.0.0.1:9000 -c d:\xampp\php\php.ini 2.nginx conf配置如下: #user nobody; ...

  10. webstorm启动报错

    环境: 在重装完系统的电脑上第一次安装webstorm, 问题: 解决”failed to load jvm dll“的报错问题: 解决方案: 安装Microsoft Visual C++ 2010 ...