CodeForces 669D Little Artem and Dance
模拟。
每个奇数走的步长都是一样的,每个偶数走的步长也是一样的。
记$num1$表示奇数走的步数,$num2$表示偶数走的步数。每次操作更新一下$num1$,$num2$。最后输出。
#pragma comment(linker, "/STACK:1024000000,1024000000")
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<vector>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<iostream>
using namespace std;
typedef long long LL;
const double pi=acos(-1.0),eps=1e-;
void File()
{
freopen("D:\\in.txt","r",stdin);
freopen("D:\\out.txt","w",stdout);
}
template <class T>
inline void read(T &x)
{
char c=getchar(); x=;
while(!isdigit(c)) c=getchar();
while(isdigit(c)) {x=x*+c-''; c=getchar();}
} bool f;
int n,q,num1,num2;
int ans[]; int M(int x)
{
if(x>=) return x%n;
int y=-x; int p=y/n+;
return (x+n*p)%n;
} int main()
{
scanf("%d%d",&n,&q); f=;
for(int i=;i<=q;i++)
{
int op; scanf("%d",&op);
if(op==)
{
int x; scanf("%d",&x);
num1=M(num1+x), num2=M(num2+x);
if(x%!=) f=f^;
}
else
{
if(f==) num2=M(num2+), num1=M(num1-);
else num1=M(num1+), num2=M(num2-);
f=f^;
}
} for(int i=;i<=n;i++)
{
int pos;
if(i%==) pos=(i+num2)%n;
else pos=(i+num1)%n; if(pos==) pos=n;
ans[pos]=i;
}
for(int i=;i<=n;i++) printf("%d ",ans[i]);
printf("\n");
return ;
}
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 想法题 多余操作
http://codeforces.com/problemset/problem/669/D 题意:n个数1~N围成一个圈.q个操作包括操作1:输入x, 所有数右移x.操作2:1,2位置上的数(swa ...
- 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 ...
- 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. ...
- codeforces668b //Little Artem and Dance// Codeforces Round #348
题意:2种操作,转动或者奇偶位互换. 不论怎么交换,1的后两位一定是3,3的后两位一定是5.因此只要记录1,2的位置. //#pragma comment(linker,"/STACK:10 ...
随机推荐
- Unknown
鉴于自己的直觉总是很准,所以这次再相信一次好了 T1:我觉得极有可能考到的是 1.对于栈,队列的模拟: 2.数论(不是像gcd那样的题目,而是加法原理乘法原理斥容,或是极具数学推导的东西,当然有可能用 ...
- C/C++基础知识总结——C++简单程序设计
1. sizeof 1.1 sizeof(类型名) 1.2 sizeof 表达式 1.3 返回所占字节大小 2. I/O流的输出格式 2.1 常用I/O流库操纵符 dec 十进制 he ...
- cocos2d(CCSprite绑定不规则刚体与精灵一起移动)
对于不规则的精灵我们可以借助PhysicsEditor来制作shape , 对于地图可以使用Tiled软件制作瓷砖地图. 今天主要记录一下如何把CCSprite与不规则刚体进行绑定,然后一起移动 // ...
- 尽量不用char*作为hash_map的key
引子: 同事前几天用hash_map时发现一些问题.当时的场景是有一些字符串char*,要去对应某种类型的对象.同事的做法是: 尝试用char*作为key进行hash.编译通过,但运行时不正常,ins ...
- 去除scons构建动态库的前缀lib
如何使用scons构建工程,请参考快速构建C++项目工具Scons,结合Editplus搭建开发环境. 编译SharedLibrary项目的时候,生产的so文件时自动加上lib, 例如: env = ...
- [学习笔记] TensorFlow 入门之基本使用
整体介绍 使用 TensorFlow, 你必须明白 TensorFlow: 使用图 (graph) 来表示计算任务. 在被称之为 会话 (Session) 的上下文 (context) 中执行图. 使 ...
- Software Industry Revolution----POJ3898----DP
题目地址:http://poj.org/problem?id=3898 题目意思: 给你一个模式串,再给你一个原串,要你去匹配 模式串里面的?可对应任意一个字符 *号可对应0个或多个字符 其中a=1, ...
- 内核操作系统Linux内核变迁杂谈——感知市场的力量
本篇文章个人在青岛游玩的时候突然想到的...今天就有想写几篇关于内核操作系统的博客,所以回家到以后就奋笔疾书的写出来发表了 Jack:什么是操作系统? 我:你买了一台笔记本,然后把整块硬盘彻底格式化, ...
- 以helloworld为例讲解magento中控制器的工作
1.下面介绍的前提是你已经安装了magento ,版本是1.9.1.0. 2.下面是实际步骤 ①在工程下面创建下面的文件目录 app/code/local/Magentotutorial/Hellow ...
- Android RecyclerView体验(一)- 简介
在网上关于RecyclerView的基本使用方式已经有了比较详细介绍,而且其设计结构也类似于ListView,所以本文将不重点介绍如何使用,在文末的引用中都可以相关内容.这里主要是介绍Recycler ...