Educational Codeforces Round 11B. Seating On Bus 模拟
地址:http://codeforces.com/contest/660/problem/B
题目:
1 second
256 megabytes
standard input
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.
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.
Print m distinct integers from 1 to m — the order in which the passengers will get off the bus.
2 7
5 1 6 2 7 3 4
9 36
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 模拟的更多相关文章
- codeforces 660B B. Seating On Bus(模拟)
题目链接: B. Seating On Bus time limit per test 1 second memory limit per test 256 megabytes input stand ...
- Educational Codeforces Round 2 A. Extract Numbers 模拟题
A. Extract Numbers Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/600/pr ...
- Educational Codeforces Round 52D(ARRAY,模拟最短路)
#include<bits/stdc++.h>using namespace std;int n,x;int chess[17*17];//记录棋盘上的numberarray<int ...
- Educational Codeforces Round 37
Educational Codeforces Round 37 这场有点炸,题目比较水,但只做了3题QAQ.还是实力不够啊! 写下题解算了--(写的比较粗糙,细节或者bug可以私聊2333) A. W ...
- Educational Codeforces Round 35 (Rated for Div. 2)
Educational Codeforces Round 35 (Rated for Div. 2) https://codeforces.com/contest/911 A 模拟 #include& ...
- Educational Codeforces Round 58 (Rated for Div. 2) 题解
Educational Codeforces Round 58 (Rated for Div. 2) 题目总链接:https://codeforces.com/contest/1101 A. Min ...
- Educational Codeforces Round 32
http://codeforces.com/contest/888 A Local Extrema[水] [题意]:计算极值点个数 [分析]:除了第一个最后一个外,遇到极值点ans++,包括极大和极小 ...
- 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. ...
- Educational Codeforces Round 64 部分题解
Educational Codeforces Round 64 部分题解 不更了不更了 CF1156D 0-1-Tree 有一棵树,边权都是0或1.定义点对\(x,y(x\neq y)\)合法当且仅当 ...
随机推荐
- zend studio 10.6.2 字体大小 设置
如果汉化的:窗体-->常规-->外观-->颜色和字体-->基本-->文字字体 点击编辑 如果未汉化:Window->Preferences->General ...
- GridLayout 可使容器中的各个组件呈网格状布局
GridLayout 可使容器中的各个组件呈网格状布局,平局占据容器的空间,即使容器的大小发生变化,每个组件还是平均占据容器的空间. 和FlowLayout一样,GridLayout也是按照从上到下, ...
- Visual Studio 2010自动添加头部注释信息
在日常的开发中我们经常需要为我们的类库添加注释和版权等信息,这样我们就需要每次去拷贝粘贴同样的文字,为了减少这种重复性的工作,我们可以把这些信息保存在Visual Studio 2010类库模版文件里 ...
- spark(1.1) mllib 源码分析(二)-相关系数
原创文章,转载请注明: 转载自http://www.cnblogs.com/tovin/p/4024733.html 在spark mllib 1.1版本中增加stat包,里面包含了一些统计相关的函数 ...
- JavaScript修改IE注册表
http://www.cnblogs.com/zmc/p/3373812.html <script type="text/javascript"> var obj = ...
- App上传到应用宝的一些问题
问题:提示应用需要认领,怎么解决? 原因:如果app之前在其他市场上传过,再上传到应用宝,应用宝首先会从其他应用市场抓包,如果发现抓取的包和上传的app包名都是一致的,这时候提示你需要认领app. 操 ...
- JavaScript------获取表单信息
<form name="fname"> <input type="text" name="user" /> < ...
- C#实现动态编译代码
/*------------------------------------------------------------------------------ * Copyright (C) 201 ...
- java的Date类型转换为MySQL数据库的Date类型
最近遇到一个问题,需要把java中的日期类型存放为MySQL数据库的日期类型,两个日期之间需要进行转化才能进行存储,转化代码如下: package com.alphajuns.demo1; impor ...
- Kotlin——初级篇(八):关于字符串(String)常用操作汇总
在前面讲解Kotlin数据类型的时候,提到了字符串类型,当然关于其定义在前面的章节中已经讲解过了.对Kotlin中的数据类型不清楚的同学.请参考Kotlin--初级篇(三):数据类型详解这篇文章. 在 ...