Educational Codeforces Round 11B. Seating On Bus 模拟
地址: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 outputConsider 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.
#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[110][5]; int main (void) { int n,m; cin>>n>>m; memset(seat,0,sizeof(seat)); for(int i=1;i<=m;i++) if(i<=2*n) { if(i%2 == 1) seat[(i+1)/2][2] = i; else seat[i/2][4] = i; } else { int t = i-2*n; if(t%2 == 1) seat[(t+1)/2][1]=i; else seat[t/2][3] = i; } for(int i=1,k=1;k<=m && i<=n;i++) for(int j = 1;j<=4;j++) if(seat[i][j]) { if(k == m) printf("%d\n",seat[i][j]); else printf("%d ",seat[i][j]); k++; } return 0; }View Code
- PL/SQL练习题三(分析函数)
- foreach获得循环次数
- 数据库系统原理设计--论坛系统
- git 常用操作
- 虚幻4 Task小记
- (转)从一道面试题来搞清楚数组指针
- 3518e问题集锦
- java--连接数据库--mysql--介绍
- BZOJ 3747 POI2015 Kinoman
- Tablayout+Viewpager+Fragment实现滑动Tab及cannot convert from Fragment1 to Fragment之解决
- 服务器对比
- linux下tomcat连接mysql数据库
- powerDesigner 连接Oracle 报Unable to connect SQLState=08004 解决方法
- leetcode 66. Plus One
- C. Animals
- 各种常用正则表达式
- Swift 自己主动引用计数机制ARC
- 结对编程—电梯调度
- 剑指offer-面试题33:把数组排成最小的数
- Eclipse+Maven创建webapp项目