地址: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
2 7
output
5 1 6 2 7 3 4
input
9 36
output
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

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

 #include <iostream>
#include <algorithm>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <queue>
#include <stack>
#include <map>
#include <vector> #define PI acos((double)-1)
#define E exp(double(1))
using namespace std;
int seat[][];
int main (void)
{
int n,m;
cin>>n>>m;
memset(seat,,sizeof(seat));
for(int i=;i<=m;i++)
if(i<=*n)
{
if(i% == )
seat[(i+)/][] = i;
else
seat[i/][] = i;
}
else
{
int t = i-*n;
if(t% == )
seat[(t+)/][]=i;
else
seat[t/][] = i;
}
for(int i=,k=;k<=m && i<=n;i++)
for(int j = ;j<=;j++)
if(seat[i][j])
{
if(k == m)
printf("%d\n",seat[i][j]);
else
printf("%d ",seat[i][j]);
k++;
} return ;
}

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. 总结 一下UML 类图的关系

    1,实线三角 表示 泛化  是一种继承关系,它指定了子类如何特化父类的所有特征和行为 2,虚线三角 表示 实现  是一种类与接口的关系,表示类是接口所有特征和行为的实现 3,空心菱形 表示 聚合 是整 ...

  2. Duilib教程-非DUI控件

    DUILIB并不是真正的DUI,至少有部分控件不是完全DUI的.其实包括: 1.EDIT. 它的实现原理是,CEditUI包含一个窗口CEditWnd,流程如下: 1)鼠标单击,创建窗口见 EditU ...

  3. 【bzoj4872】[Shoi2017]分手是祝愿 数论+期望dp

    题目描述 Zeit und Raum trennen dich und mich. 时空将你我分开. B 君在玩一个游戏,这个游戏由 n 个灯和 n 个开关组成,给定这 n 个灯的初始状态,下标为从 ...

  4. 讨论cocos2d-x字体绘制原理和应用方案

    转自:http://blog.csdn.net/langresser_king/article/details/9012789 个人一直认为,文字绘制是cocos2d-x最薄弱的环节.对于愤怒的小鸟之 ...

  5. delphi---EHlib第三方插件----TDBGridEH,TDBNumberEditEh,TDBComboBoxEh

    一.TDBGridEH 1.多选 行 options->dgMultiSelect 2.列字体改变颜色,OnDrawColumnCell写下方法. if Column.FieldName='价格 ...

  6. c#学习笔记之使用 TableLayoutPanel 控件设置窗体布局

    使用 TableLayoutPanel 控件设置窗体布局 在 Visual Studio IDE 左侧,找到“工具箱”选项卡. 选择“工具箱”选项卡,随即将显示工具箱.(或者,在菜单栏上,依次选择“视 ...

  7. Powershell Get-FileHash

    File Hash (Get-FileHash C:\fso\myfile.txt).hash Get-FileHash C:\Users\Andris\Downloads\Contoso8_1_EN ...

  8. java.lang.IllegalStateException: Queue full

    其实异常说的很清楚 队列满了! ArrayBlockingQueue FIFO 的队列: ArrayBlockingQueue内部是通过一个Object数组和一个ReentrantLock实现的.同时 ...

  9. Android 中 js 和 原生交互

    Android中的WebView 中加载的URL 默认是在手机浏览器中加载的,我们可以覆盖这种默认的动作,让网页在WebView中打开.通过设置WebView的WebViewClent 达到这个效果. ...

  10. 如何cancel掉慢查询

    百度Elasticsearch-产品描述-介绍-百度云 https://cloud.baidu.com/doc/BES/FAQ.html#.E5.A6.82.E4.BD.95cancel.E6.8E. ...