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 ...
随机推荐
- spring中Bean创建
Spring中bean的加载过程: 1.获取配置文件资源 2.对获取的xml资源进行一定的处理检验 3.处理包装资源 4.解析处理包装过后的资源 5.加载提取bean并注册(添加到beanDefini ...
- My app status is Ready for Sale but I cannot see my app on the App Store. Why? 为什么审核通过后 appstore中搜不到我的app
这是苹果的官方解答 The following factors could prevent your app from showing up on the App Store: Make sure t ...
- dsp端编译异常之max和min未定义
(1)在函数之前 声明__stdcall 时 在linux 端或dsp端 linux 之前的加上宏定义 __stdcall是MS的编译器使用的只需要#define __stdcall定义一个宏就可以 ...
- 利用easyUI的combobox打造自己主动提示组件
自己主动提示是时下一个非常流行的功能,比方说百度.谷歌的搜索输入框都使用到了这么一个功能. 因为easyUI的combobox设计师已经考虑到了这个功能.所以仅仅需简单几步我们能够轻松打造自己的自己主 ...
- mysql数据库隔离级别及其原理、Spring的7种事物传播行为
一.事务的基本要素(ACID) 1.原子性(Atomicity):事务开始后所有操作,要么全部做完,要么全部不做,不可能停滞在中间环节.事务执行过程中出错,会回滚到事务开始前的状态,所有的操作就像没有 ...
- /dev下添加设备节点的方法步骤(通过device_create)
将自己开发的内核代码加入到Linux内核中,需要3个步骤: 1.确定把自己开发代码放入到内核合适的位置 将demo_chardev.c文件拷贝到.../drivers/char/目录下. demo_c ...
- bzoj3134: [Baltic2013]numbers
稍微用脑子想一想,要是一个回文数,要么s[i]==s[i+1]要么s[i]==s[i+2]就可以实锤了 所以多开两维表示最近两位选的是什么数就完了 注意前导0 #include<cstdio&g ...
- HDU3652 B-number —— 数位DP
题目链接:https://vjudge.net/problem/HDU-3652 B-number Time Limit: 2000/1000 MS (Java/Others) Memory L ...
- docker hub下载慢解决方法 使用daocloud的mirror
见:http://blog.csdn.net/dingsai88/article/details/52638758
- hadoop datanode启动失败(All directories in dfs.data.dir are invalid)
由于hadoop节点的磁盘满了,导致节点死掉,今天对其进行扩容.首先,将原节点的数据拷贝到目标节点下,从而避免数据的丢失,但是在执行hadoop_daemon.sh start datanode后没有 ...