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)\)合法当且仅当 ...
随机推荐
- ThinkPHP 模板 Volist 标签嵌套循环输出多维数组
ThinkPHP 中对 volist 标签嵌套使用可实现多维数组的输出. volist 嵌套使用 一般的二维数组,可以用 volist 标签直接循环输出.对于多维数组,则需要对其中的数组成员再次使用 ...
- C语言 函数指针二(正向调用)
//函数指针做函数参数 #include<stdio.h> #include<stdlib.h> #include<string.h> #include<Wi ...
- win10执行shell脚本
我们在win10如何执行以.sh文件的脚本呢? 开发步骤:1.写脚本b2q_goods.sh #!/bin/bashsql="select * from b2q.goods where go ...
- 从thinkphp到php到ajax
因为thinkphp的ajax非常麻烦,所以采用了php辅助,辅助的过程必然要只有一个连接字符串,但是却不能异步了 如果单独的在页面写连接字符串,不引用,那么页面又返回正常
- 异步 - True 或 False?
异步 - True 或 False? AJAX 指的是异步 JavaScript 和 XML(Asynchronous JavaScript and XML). XMLHttpRequest 对象如果 ...
- .NET中二进制图片的存储与读取
判断HttpContext是否为空: string configPath = "img/defaultPhoto.png"; if (HttpContext.Current != ...
- git 入门一(初识)
分布式版本控制系统 & 集中式版本控制系统 分布式版本控制系统( Distributed Version Control System)在这类系统中,像 Git,Mercurial,Baz ...
- VC++ 判断你的窗口是否置顶TopMost
大家可能已经知道,使你的窗口置顶(TopMost)或者总是最前(Always on Top)的方法: C++ Code 12345 // Make topmost , SWP_NOMOVE | ...
- Linux下RPM包管理
概述 一种用于互联网下载包的打包及安装工具,它包含在某些linux分发版中.它生成具有.RPM扩展名的文件.RPM是Redhat Package Manager(Redhat软件包管理工具)的缩写.这 ...
- CNBlog客户端--项目介绍以及技术选型
项目背景 由于现在开始在博客园写博客,再加上我是android程序员!所以呢,就自然而然的想到自己开发一个自己认为"美"的客户端!!其实还有个原因就是最近我比较闲!!纯属自己给自己 ...