地址: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. python笔记2-数据类型:元组、字典常用操作

    元组 Python的元组与列表类似,不同之处在于元组的元素不能修改. 元组使用小括号,列表使用方括号. 元组创建很简单,只需要在括号中添加元素,并使用逗号隔开即可. tp=(1,2,3,'a','b' ...

  2. 第一百六十二节,jQuery入门介绍

    jQuery入门 学习要点: 1.什么是  jQuery 2.学习 jQuery的条件 3.jQuery的版本 4.jQuery的功能和优势 5.其他 JavaScript库 6.是否兼容低版本  I ...

  3. ListView setOnItemClickListener无效原因具体分析

    前言 近期在做项目的过程中,在使用listview的时候遇到了设置item监听事件的时候在没有回调onItemClick 方法的问题. 我的情况是在item中有一个Buttonbutton. 所以不会 ...

  4. vue项目创建步骤小结

    第一步创建项目目录demo cd demo npm init  生成package.json 初始化项目工具使用 命令行工具 (CLI) 快速初始化 # 全局安装 vue-cli $ npm inst ...

  5. MYSQL批量插入数据库实现语句性能分析【转】 批量插入!程序里面对于数据库插入的功能尽量用【异步处理+批量插入+(事务)】

    假定我们的表结构如下 代码如下   CREATE TABLE example (example_id INT NOT NULL,name VARCHAR( 50 ) NOT NULL,value VA ...

  6. Yolo+Windows 配置(详细版)

    一.配置环境  VS2013+显卡GtX1080ti+CUDA7.5+Opencv3.1.0+pthread pthread:ftp://sourceware.org/pub/pthreads-win ...

  7. android应用安全——代码安全(android代码混淆)

    android2.3的SDK开始在eclipse中支持代码混淆功能(理论上java都支持混淆,但关键在于如何编写proguard的混淆脚本,2.3的SDK使用简单的配置就可以实现混淆).使用SDK2. ...

  8. Poj1426

    Find The Multiple Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 25721   Accepted: 106 ...

  9. ORACLE的测试用户Scott

    Oracle数据库的测试用户Scott的密码为什么是Tiger? 1977年6月,Larry Ellison 与 Bob Miner 和 Ed Oates 在硅谷共同创办了一家名为软件开发实验室(So ...

  10. iOS接收远程通知响应方法

    点击 iOS 接收远程推送主要牵扯到的方法有以下五种 (1) - (BOOL)application:(UIApplication *)application didFinishLaunchingWi ...