Content

有 \(n+1\) 个碟,编号为 \(0\sim n\),一开始 \(0\) 号碟在播放机上,其他的碟依次放进了 \(n\) 个盒子里面。现在有 \(m\) 次操作,每次操作找到当前在盒子里面的编号为 \(x\) 的碟并和当前正在播放机上的碟交换,求 \(m\) 次操作后 \(n\) 个盒子里面的碟的编号。

数据范围:\(1\leqslant n\leqslant 100,0\leqslant m\leqslant 100,1\leqslant x\leqslant n\)。

Solution

直接暴力扫一遍,找到了就和当前在播放机上的碟交换一下,最后再输出一下在盒子里面的碟的编号即可。

Code

int n, m, a[100007], x;

int main() {
//This program is written in Windows 10 by Eason_AC
getint(n), getint(m);
_for(i, 0, n) a[i] = i;
while(m--) {
getint(x);
_for(i, 1, n) if(a[i] == x) {swap(a[0], a[i]); break;}
}
_for(i, 1, n) writeint(a[i]), puts("");
return 0;
}

最新文章

  1. 如何在Visual Studio 2012中发布Web应用程序时自动混淆Javascript
  2. html中select标签根据枚举获得值的总结
  3. java中异常注意问题(发生在多态是的异常问题)
  4. Gym 100917J---dir -C(RMQ--ST)
  5. memcached与.NET的融合使用(一)
  6. Jenkins进阶系列之——05FTP publisher plugin插件
  7. Git 一些日常使用积累
  8. WebStorm快捷键收集
  9. 封装Unity3d的dll时的经验总结
  10. 工厂方法模式(java 设计模式)
  11. java foreach循环为什么不能赋值
  12. boost signal2 slot_base
  13. 转载:做Java开发这一年 (火龙果软件)
  14. MyEclipse解决SVN同步冲突问题conflict in the working copy obstructs the current operation
  15. WaitForSingleObject函数
  16. T-SQL动态查询(1)——简介
  17. markdown特殊符号语法
  18. Python列表详解
  19. 每日英语:A Buying Guide to Air-Pollution Masks
  20. 第二十四天- 模块导入 import from xxx import xxx

热门文章

  1. No 'Access-Control-Allow-Origin' header: 跨域问题踩坑记录
  2. linux下vim的安装与配置(centos)
  3. 【模板】缩点(Tarjan算法)/洛谷P3387
  4. 使用GitHub Action进行打包并自动推送至OSS
  5. A Child's History of England.16
  6. A Child's History of England.18
  7. Qt5的安装和编译
  8. HTML5 基础内容(元素/属性/格式化)
  9. 【leetcode】563. Binary Tree Tilt
  10. C++ 德才论