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 ...
随机推荐
- Linux Shell脚本攻略
-Linux Shell脚本攻略 总结的来说,这本书很实践性和实用性强,都是给的具体的例子,直接可以在终端操作实践,比单纯只看不动手务实多了,另外就是,这本书涵盖的内容也比较广,从文本操作到服务器管理 ...
- c/c++操作访问数据,是堆中的数据快还是栈中的数据快
这里的问题其实问的是对堆与栈的数据访问有什么不同. 观察如下代码: #include<stdio.h> #include<iostream> using namespace s ...
- MongoDB:利用官方驱动改装为EF代码风格的MongoDB.Repository框架 三
本次改动的主要内容是实现MongoDB.Repository在MongoDB中建立索引. 建立索引主要使用MongoDB的官方驱动中EnsureIndex方法. 在MongoDB.Repository ...
- defer 与 async
defer HTML4.01定义的 只适用于外部脚本(IE4~7会支持内嵌脚本的defer属性) 告诉浏览器立即下载,延迟执行,脚本会延迟到整个页面全部解析完毕之后才运行 HTML5规范要求脚本按照他 ...
- ie7,8下__flash__addCallback报错原因及解决方案
首先附张图,以直观说明错误的现象:(ie7.8)
- 数组和Hash表
数组和Hash表 当显示多条结果时,存储在变量中非常智能,变量类型会自动转换为一个数组. 在下面的例子中,使用GetType()可以看到$a变量已经不是我们常见的string或int类型,而是Obje ...
- breakpad是Google开源的一套跨平台工具
windows下捕获dump之Google breakpad_client的理解 breakpad是Google开源的一套跨平台工具,用于dump的处理.很全的一套东西,我这里只简单涉及break ...
- EF Code First、DbContext
EF Code First.DbContext 对于之前一直使用webForm服务器控件.手写ado.net操作数据库的同学,突然来了EF和MVC,好多新概念一下泉涌而出,犹如当头一棒,的确有点不知所 ...
- 基于Redis缓存的Session共享(附源码)
基于Redis缓存的Session共享(附源码) 在上一篇文章中我们研究了Redis的安装及一些基本的缓存操作,今天我们就利用Redis缓存实现一个Session共享,基于.NET平台的Seesion ...
- Internet Liberity -- a specific anonymous internet guide
Here we see. Please leave your comments if you have some views. Happy hacking! Free the internet!