http://codeforces.com/problemset/problem/669/D

题目大意: 有n对人 男生和女生 开始时  每个人的标号是(1,2,3,。。。n) 女生们围成一个圈  男生在外面围成一个圈

有q个操作  第一种情况是  如果x>0男生顺时针走x步  否则  逆时针走

第二种情况是  男生现在对应的女生的编号如果是奇数  这个男生就跟对应的女生的编号是偶数的男生交换位置

最后输出每个男生的编号

分析:  我们可以想到 其实奇数编号的男生移动的是一样的   偶数也是

我们就用两个参数 代表奇数编号的男生  和偶数编号的男生  的移动的位置数

#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<ctype.h>
#include<math.h>
#include<queue>
#include<algorithm>
#include<iostream> using namespace std;
#define N 5000050
const double ESP = 1e-;
#define INF 0x3f3f3f3f
#define memset(a,b) memset(a,b,sizeof(a))
int a[N],s[N];
int main()
{
int n,q; while(scanf("%d %d",&n,&q)!=EOF)
{
int t=;
int v=;
int j,o;
j=o=;
for(int i=;i<q;i++)
{
scanf("%d",&t);
if(t==)
{
scanf("%d",&v);
j+=v;
o+=v;
}
else
{
if(j%==)
j++;
else
j--;
if(o%==)
o--;
else
o++;
}
j=(j+n)%n;
o=(o+n)%n;
}
for(int i=;i<n;i++)
{
if(i%==)
{
a[i]=i+j;
a[i]=a[i]%n;
s[a[i]+]=i+;
}
else
{
a[i]=i+o;
a[i]=a[i]%n;
s[a[i]+]=i+;
}
}
for(int i=;i<=n;i++)
{
printf("%d ",s[i]);
}
printf("\n");
}
return ;
}

D. Little Artem and Dance---cf669D的更多相关文章

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

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

  3. D. Little Artem and Dance

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

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

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

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

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

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

  7. Codeforces Round #348 (VK Cup 2016 Round 2, Div. 2 Edition) D. Little Artem and Dance

    题目链接: http://codeforces.com/contest/669/problem/D 题意: 给你一个初始序列:1,2,3,...,n. 现在有两种操作: 1.循环左移,循环右移. 2. ...

  8. CodeForces 669D Little Artem and Dance

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

  9. codeforces668b //Little Artem and Dance// Codeforces Round #348

    题意:2种操作,转动或者奇偶位互换. 不论怎么交换,1的后两位一定是3,3的后两位一定是5.因此只要记录1,2的位置. //#pragma comment(linker,"/STACK:10 ...

  10. CodeForces - 669D Little Artem and Dance 想法题 多余操作

    http://codeforces.com/problemset/problem/669/D 题意:n个数1~N围成一个圈.q个操作包括操作1:输入x, 所有数右移x.操作2:1,2位置上的数(swa ...

随机推荐

  1. Openrisc的or1200

    1 什么是OpenRISC OpenRISC 是硬件开源社区opencores开发的RISC指令集处理器架构,包括32 bits 的Openrisc1000 和64 bitsOpenrisc 2000 ...

  2. yum install perl-ExtUtils-MakeMaker

    Can't locate ExtUtils/MakeMaker.pm in @INC (@INC contains: /usr/local/lib/perl5 /usr/local/share/per ...

  3. springboot的多个配置文件的关系

    一般我们在使用springboot时会用到多个环境下的配置文件,例如 application-dev.yml:开发环境 application-uat.yml:用户验收测试环境 application ...

  4. 使用libsvm实现文本分类

    @Hcy(黄灿奕) 文本分类,首先它是分类问题,应该对应着分类过程的两个重要的步骤,一个是使用训练数据集训练分类器,另一个就是使用测试数据集来评价分类器的分类精度.然而,作为文本分类,它还具有文本这样 ...

  5. 4.03 使用NULL代替默认值

    问题:在一个定义了默认值的列插入数据,并且需要不管该列的默认值是什么,都将该列值设为NULL.考虑一下下面的表: create table D (id interger default 0, foo ...

  6. C++中static,extern和extern "C"关键字

    1. extern 变量 extern 表明该变量在别的地方已经定义过了,在这里要使用那个变量. 当extern不与"C"在一起修饰变量或函数时,如在头文件中: extern in ...

  7. pymysql遇到中文编码

    明明数据库里的编码方式和字符集都没有问题,用python插入数据时,数据库里的数据还是乱码的 在数据库中插入时,能够正常显示 那就是python导出的数据存在编码问题,代码如下: # coding: ...

  8. POJ-2442-Sequence(二叉堆)

    POJ-2442 Description Given m sequences, each contains n non-negative integer. Now we may select one ...

  9. MySQL Utilities管理工具

    前提: 1.安装MySQL Utilities工具 2.复制my_print_defaults命令至/usr/bin下或写入环境变量. 卸载方式: python ./setup.py clean -- ...

  10. Android API Guides 安卓API指导----第一部分:Introduction(介绍)

    第一部分: Introduction(介绍) 目录包含:APP  Fundamentals     (应用程序基础) Device   Compatibility(设备兼容性) System Perm ...