• NEW RDSP MODE I

  • 时间限制: 1000 ms 内存限制: 131072 K
  • 问题描述
  • Little A has became fascinated with the game Dota recently, but he is not a good player. In all the modes, the rdsp Mode is popular on online, in this mode, little A always loses games if he gets strange heroes, because, the heroes are distributed randomly.

    Little A wants to win the game, so he cracks the code of the rdsp mode with his talent on programming. The following description is about the rdsp mode:

    There are N heroes in the game, and they all have a unique number between 1 and N. At the beginning of game, all heroes will be sorted by the number in ascending order. So, all heroes form a sequence One.

    These heroes will be operated by the following stages M times:

    1.Get out the heroes in odd position of sequence One to form a new sequence Two;

    2.Let the remaining heroes in even position to form a new sequence Three;

    3.Add the sequence Two to the back of sequence Three to form a new sequence One.

    After M times' operation, the X heroes in the front of new sequence One will be chosen to be Little A's heroes. The problem for you is to tell little A the numbers of his heroes.

  • 输入
  • There are several test cases.
    Each case contains three integers N (1<=N<1,000,000), M (1<=M<100,000,000), X(1<=X<=20).
    Proceed to the end of file.
  • 输出
  • For each test case, output X integers indicate the number of heroes. There is a space between two numbers. The output of one test case occupied exactly one line.
  • 样例输入
  • 5 1 2
    5 2 2
  • 样例输出
  • 2 4
    4 3
  • 提示
  • In case two: N=5,M=2,X=2,the initial sequence One is 1,2,3,4,5.After the first operation, the sequence One
    is 2,4,1,3,5. After the second operation, the sequence One is 4,3,2,1,5.So,output 4 3.
  • 来源
  • 辽宁省赛2010

题意:有1~n这样n个有序的数,每次抽出其中奇数位的放到最后,偶数位的放在前面,操作m次,问前x个数分别为什么

解题思路:暴力操作一次,找出每个位置是从上次哪个位置来的,用这个规律就可以找出循环节,也就是操作几次能够变回一开始的样子,m对循环节进行取余,然后对x位暴力地进行剩余次数的模拟

#include <iostream>
#include <cstdio>
#include <cstring>
#include <string>
#include <map>
#include <set>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <stack>
#include <functional>
#include <climits>using namespace std;#define LL long long
const int INF=0x3f3f3f3f;int f[1000009];
int n,m,x;int main()
{while(~scanf("%d%d%d",&n,&m,&x)){int cnt=1;for(int i=2;i<=n;i+=2) f[cnt++]=i;for(int i=1;i<=n;i+=2) f[cnt++]=i;int pos=f[1];int res=1;while(pos!=1){res++;pos=f[pos];}m%=res;int flag=0;for(int i=1;i<=x;i++){if(flag) printf(" ");else flag=1;int k=i;for(int j=1;j<=m;j++)k=f[k];printf("%d",k);}printf("\n");}return 0;
}

NBUT1225-NEW RDSP MODE I相关推荐

  1. NBUT1225 NEW RDSP MODE I(快速幂,规律)

    题目: [1225] NEW RDSP MODE I 时间限制: 1000 ms 内存限制: 131072 K 问题描述 Little A has became fascinated with the ...

  2. NBUT1225 NEW RDSP MODE I(快速幂,规律):

    G - NEW RDSP MODE I NBUT - 1225 题意: ​ 给你三个数n,n,n,mmm,xxx.代表刚开始有1到n1 到n1到n刚好n个数,现在让你将序列变换mmm次,问你变换mmm ...

  3. 模拟 nbut1225 NEW RDSP MODE I

    传送门:点击打开链接 题意:输入n.m,x.刚開始有一个1~n的排列.然后定义了一种操作.是将数组中的偶数位数字选出来,依照顺序放到数组最前面,奇数位依照顺序放到偶数位的后面,进行m次这种操作.输出之 ...

  4. LDU暑假集训(十)1209 Problem I NEW RDSP MODE I

    题目描述 Little A has became fascinated with the game Dota recently, but he is not a good player. In all ...

  5. NEW RDSP MODE I

    题目描述 Little A has became fascinated with the game Dota recently, but he is not a good player. In all ...

  6. NEW RDSP MODE I (快速幂)

    题目: 问题 : NEW RDSP MODE I 题目描述 Little A has became fascinated with the game Dota recently, but he is ...

  7. NBUT 1225 NEW RDSP MODE I

    [1225] NEW RDSP MODE I 时间限制: 1000 ms 内存限制: 131072 K 问题描述 Little A has became fascinated with the gam ...

  8. 辽宁2010省赛NEW RDSP MODE I (思维,推导公式)

    我感觉这辈子是想不到了,看了大佬的题解,才知道自己有多菜. 翻译: 小A最近对Dota的比赛着迷,但他不是一个好球员.在所有模式中,rdsp模式在网上流行,在这种模式下,如果他得到奇怪的英雄,小A总是 ...

  9. NEW RDSP MODE I (模拟,循环节)

    题目链接:https://cn.vjudge.net/problem/NBUT-1225 [题意] 给一个1-n的序列,经过m次操作,输出前m个数字. 具体操作是把序列的偶数项按顺序提到奇数位的前面. ...

最新文章

  1. PostgreSQL 8.2.5 安装为 Windows 服务 (Service)
  2. python【蓝桥杯vip练习题库】BASIC-3字母图形
  3. Oracle12g添加c##scott用户
  4. 文件写入的6种方法,这种方法性能最好
  5. 为SQLMap配置WebUI界面
  6. Visual Studio SnippetDesigner使用
  7. KVM虚拟机迁移原理分析
  8. python从url获取pdf文件并保存在本地
  9. 文件那些事儿之一(初稿)
  10. aws终止实例后还收费吗_「技术选型」AWS 和 AZURE的全面比较
  11. 使用JSON作为函数的参数(转载)
  12. Fundebug前端JavaScript插件更新至1.6.0,新增test()方法用于测试 1
  13. oracle系统FA调整折旧年限,Oracle财务管理系统培训手册.doc
  14. Android 使用Loader轻松实现仿微信图片加载
  15. Beta冲刺第二周王者荣耀交流协会第三次会议
  16. 关于 Python PyQt5 界面运行时提示无法初始化Qt平台的解决方案
  17. far manager引出的windows编码问题
  18. 分析:中国股市独步天下
  19. 认清面向服务架构(SOA)的本来面目
  20. 语音控制开关灯----mega2560

热门文章

  1. 黑马python培训_要一张纯黑的图片。纯黑的。
  2. 深入理解空洞卷积:优点以及存在问题
  3. CSDN官方markdown教程
  4. 【蓝桥杯省赛】冲刺练习题【枚举】倒计时【12】天
  5. 苏宁成立智能终端公司 并发布BiuOS及10款智能硬件
  6. snprintf函数
  7. 拓嘉辰丰电商:如何投诉拼多多商家一直不发货
  8. Java调用TSC打印机进行打印
  9. SAP CRM BOL entity deletion - root node and sub node
  10. pandas:世界各国GDP数据集数据清洗案例