地址:http://codeforces.com/contest/660/problem/B

题目:

B. Seating On Bus
time limit per test

1 second

memory limit per test

256 megabytes

input

standard input

output

standard output

Consider 2n rows of the seats in a bus. n rows of the seats on the left and n rows of the seats on the right. Each row can be filled by two people. So the total capacity of the bus is 4n.

Consider that m (m ≤ 4n) people occupy the seats in the bus. The passengers entering the bus are numbered from 1 to m (in the order of their entering the bus). The pattern of the seat occupation is as below:

1-st row left window seat, 1-st row right window seat, 2-nd row left window seat, 2-nd row right window seat, ... , n-th row left window seat,n-th row right window seat.

After occupying all the window seats (for m > 2n) the non-window seats are occupied:

1-st row left non-window seat, 1-st row right non-window seat, ... , n-th row left non-window seat, n-th row right non-window seat.

All the passengers go to a single final destination. In the final destination, the passengers get off in the given order.

1-st row left non-window seat, 1-st row left window seat, 1-st row right non-window seat, 1-st row right window seat, ... , n-th row left non-window seat, n-th row left window seat, n-th row right non-window seat, n-th row right window seat.

The seating for n = 9 and m = 36.

You are given the values n and m. Output m numbers from 1 to m, the order in which the passengers will get off the bus.

Input

The only line contains two integers, n and m (1 ≤ n ≤ 100, 1 ≤ m ≤ 4n) — the number of pairs of rows and the number of passengers.

Output

Print m distinct integers from 1 to m — the order in which the passengers will get off the bus.

Examples
input
  1. 2 7
output
  1. 5 1 6 2 7 3 4
input
  1. 9 36
output
  1. 19 1 20 2 21 3 22 4 23 5 24 6 25 7 26 8 27 9 28 10 29 11 30 12 31 13 32 14 33 15 34 16 35 17 36 18

思路:直接模拟就好了,座位位置找规律就好了,别告诉我你找不到规律、、、、

  1. #include <iostream>
  2. #include <algorithm>
  3. #include <cstdio>
  4. #include <cmath>
  5. #include <cstring>
  6. #include <queue>
  7. #include <stack>
  8. #include <map>
  9. #include <vector>
  10.  
  11. #define PI acos((double)-1)
  12. #define E exp(double(1))
  13. using namespace std;
  14. int seat[][];
  15. int main (void)
  16. {
  17. int n,m;
  18. cin>>n>>m;
  19. memset(seat,,sizeof(seat));
  20. for(int i=;i<=m;i++)
  21. if(i<=*n)
  22. {
  23. if(i% == )
  24. seat[(i+)/][] = i;
  25. else
  26. seat[i/][] = i;
  27. }
  28. else
  29. {
  30. int t = i-*n;
  31. if(t% == )
  32. seat[(t+)/][]=i;
  33. else
  34. seat[t/][] = i;
  35. }
  36. for(int i=,k=;k<=m && i<=n;i++)
  37. for(int j = ;j<=;j++)
  38. if(seat[i][j])
  39. {
  40. if(k == m)
  41. printf("%d\n",seat[i][j]);
  42. else
  43. printf("%d ",seat[i][j]);
  44. k++;
  45. }
  46.  
  47. return ;
  48. }

Educational Codeforces Round 11B. Seating On Bus 模拟的更多相关文章

  1. codeforces 660B B. Seating On Bus(模拟)

    题目链接: B. Seating On Bus time limit per test 1 second memory limit per test 256 megabytes input stand ...

  2. Educational Codeforces Round 2 A. Extract Numbers 模拟题

    A. Extract Numbers Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/600/pr ...

  3. Educational Codeforces Round 52D(ARRAY,模拟最短路)

    #include<bits/stdc++.h>using namespace std;int n,x;int chess[17*17];//记录棋盘上的numberarray<int ...

  4. Educational Codeforces Round 37

    Educational Codeforces Round 37 这场有点炸,题目比较水,但只做了3题QAQ.还是实力不够啊! 写下题解算了--(写的比较粗糙,细节或者bug可以私聊2333) A. W ...

  5. Educational Codeforces Round 35 (Rated for Div. 2)

    Educational Codeforces Round 35 (Rated for Div. 2) https://codeforces.com/contest/911 A 模拟 #include& ...

  6. Educational Codeforces Round 58 (Rated for Div. 2) 题解

    Educational Codeforces Round 58 (Rated for Div. 2)  题目总链接:https://codeforces.com/contest/1101 A. Min ...

  7. Educational Codeforces Round 32

    http://codeforces.com/contest/888 A Local Extrema[水] [题意]:计算极值点个数 [分析]:除了第一个最后一个外,遇到极值点ans++,包括极大和极小 ...

  8. Educational Codeforces Round 34 (Rated for Div. 2) A B C D

    Educational Codeforces Round 34 (Rated for Div. 2) A Hungry Student Problem 题目链接: http://codeforces. ...

  9. Educational Codeforces Round 64 部分题解

    Educational Codeforces Round 64 部分题解 不更了不更了 CF1156D 0-1-Tree 有一棵树,边权都是0或1.定义点对\(x,y(x\neq y)\)合法当且仅当 ...

随机推荐

  1. Struts2包含哪些标签?

    Struts2包含哪些标签? 解答: A: <s:a href=”"></s:a>—–超链接,类似于html里的<a></a> <s:a ...

  2. 数据挖据之GeoHash核心原理解析

    引子 机机是个好动又好学的孩子,平日里就喜欢拿着手机地图点点按按来查询一些好玩的东西.某一天机机到北海公园游玩,肚肚饿了,于是乎打开手机地图,搜索北海公园附近的餐馆,并选了其中一家用餐. 饭饱之后机机 ...

  3. [转]C# 获取指定目录下所有文件信息、移动目录、拷贝目录

    原文:http://blog.csdn.net/vchao13/article/details/6200255 1.获取指定目录下所有文件信息 /// <summary> /// 返回指定 ...

  4. python 之 赋值和拷贝(你真的了解吗)

    现象:先上一段代码. >>> import copy >>> a = [1,2,3,4,['a','b']] >>> b = a >> ...

  5. CentOS 7 64位 安装 PostgreSQL 9.2整理

    centos版本 LSB Version: :core-4.1-amd64:core-4.1-noarchDistributor ID: CentOSDescription: CentOS Linux ...

  6. @RequestMapping中method的默认值是什么?

    @RequestMapping中method的默认值是什么? 没有默认值,如果不配置method, 则以任何请求形式 RequestMethod.GET, RequestMethod.POST, Re ...

  7. [Algorithms] Longest Increasing Subsequence

    The Longest Increasing Subsequence (LIS) problem requires us to find a subsequence t of a given sequ ...

  8. filezilla 读取目录失败

    用到FTP,本来一直用主动模式,可以最近老是读取目录失败,425 Can't open data connection 和 读取目录列表失败(搞了好久,一天) 问题解决 这个问题主要是由于使用Pass ...

  9. C# 二进制文件操作(内容搜索、数据截取)

    private void button2_Click(object sender, EventArgs e) { var list = new List<Frame>(); byte[] ...

  10. 用户登陆状态,ios开发用户登陆

    IOS开发之记录用户登陆状态,ios开发用户登陆 上一篇博客中提到了用CoreData来进行数据的持久 化,CoreData的配置和使用步骤还是挺复杂的.但熟悉CoreData的使用流程后,CoreD ...