Educational Codeforces Round 11 B
Description
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
首先最左边是一个1开始,差为2的等差数列,求出最上层的数字,第二行第一个是
第一行最上层的数字+1,第三行第一个是第二行第一个数字加一,第四行是2开始,差为2的等差数列,然后按照规律输出就行
#include<stdio.h>
//#include<bits/stdc++.h>
#include<string.h>
#include<iostream>
#include<math.h>
#include<sstream>
#include<set>
#include<queue>
#include<map>
#include<vector>
#include<algorithm>
#include<limits.h>
#define inf 0x3fffffff
#define INF 0x3f3f3f3f
#define lson l,m,rt<<1
#define rson m+1,r,rt<<1|1
#define LL long long
#define ULL unsigned long long
using namespace std;
int t;
int n,m;
int sum,ans,flag;
long long b,c,d,e;
long long a[500][500];
int main()
{
cin>>n>>m;
for(int i=0;i<n;i++)
{
a[i][0]=1+i*2;
// cout<<a[i][0]<<endl;
}
a[0][1]=a[n-1][0]+2;
for(int i=1;i<n;i++)
{
a[i][1]=a[i-1][1]+2;
// cout<<a[i][1]<<endl;
}
a[0][2]=a[0][1]+1;
for(int i=1;i<n;i++)
{
a[i][2]=a[i-1][2]+2;
// cout<<a[i][2]<<endl;
}
for(int i=0;i<n;i++)
{
a[i][3]=(i+1)*2;
}
int sum=0;
e=m%4;
for(int i=0;i<n;i++)
{
if(a[i][1]&&a[i][1]<=m)
{
cout<<a[i][1]<<" ";
}
if(a[i][0]&&a[i][0]<=m)
{
cout<<a[i][0]<<" ";
}
if(a[i][2]&&a[i][2]<=m)
{
cout<<a[i][2]<<" ";
}
if(a[i][3]&&a[i][3]<=m)
{
cout<<a[i][3]<<" ";
}
} return 0;
}
Educational Codeforces Round 11 B的更多相关文章
- Educational Codeforces Round 11 C. Hard Process 前缀和+二分
题目链接: http://codeforces.com/contest/660/problem/C 题意: 将最多k个0变成1,使得连续的1的个数最大 题解: 二分连续的1的个数x.用前缀和判断区间[ ...
- Educational Codeforces Round 11
A. Co-prime Array http://codeforces.com/contest/660/problem/A 题意:给出一段序列,插进一些数,使新的数列两两成互质数,求插最少的个数,并输 ...
- Educational Codeforces Round 11 E. Different Subsets For All Tuples 动态规划
E. Different Subsets For All Tuples 题目连接: http://www.codeforces.com/contest/660/problem/E Descriptio ...
- Educational Codeforces Round 11 D. Number of Parallelograms 暴力
D. Number of Parallelograms 题目连接: http://www.codeforces.com/contest/660/problem/D Description You ar ...
- Educational Codeforces Round 11 C. Hard Process 二分
C. Hard Process 题目连接: http://www.codeforces.com/contest/660/problem/C Description You are given an a ...
- Educational Codeforces Round 11 B. Seating On Bus 水题
B. Seating On Bus 题目连接: http://www.codeforces.com/contest/660/problem/B Description Consider 2n rows ...
- Educational Codeforces Round 11 A. Co-prime Array 水题
A. Co-prime Array 题目连接: http://www.codeforces.com/contest/660/problem/A Description You are given an ...
- Educational Codeforces Round 11 _D
http://codeforces.com/contest/660/problem/D 这个题据说是很老的题了 然而我现在才知道做法 用map跑了1953ms: 题目大意 给你n个点的坐标 求这些点能 ...
- Educational Codeforces Round 11 A
A. Co-prime Array time limit per test 1 second memory limit per test 256 megabytes input standard in ...
随机推荐
- 探索Web Office Apps服务
老样子,先放几个官链: WOA部署规划:http://technet.microsoft.com/zh-cn/library/jj219435(v=office.15).aspx 拓扑规划:http: ...
- 根据/proc/meminfo对空闲内存进行占用
#include <stdio.h> #include <sys/sysinfo.h> #include <linux/kernel.h> /* 包含sysinfo ...
- 使用ffmpeg合并视频
命令: ffmpeg -i concat:"1.avi|2.avi" -vcodec copy -acodec copy "3.avi" ffmpeg下载:ht ...
- day17 12.复习
最后能抽取成word文档或者是图片之类的. 1.jdbc介绍 jdbc是一套标准,可以让我们Java程序员通过Java代码直接操作数据库,这就够了.jdbc涉及到的包两个:java.sql,java ...
- gym - 101673I Twenty Four, Again (表达式树枚举)
题意及思路 模拟场上用一般方法枚举非常麻烦,一个小时没写出来,还是自己太菜了...用表达式树枚举有一个好处,判断需不需要加括号非常方便,只有当前节点运算符的优先级高于子节点的时候,才需要给子节点加一个 ...
- Codeforces 1142B Lynyrd Skynyrd
---恢复内容开始--- 题意:给你一个排列p和数组a,有t组询问,每次询问一个区间的子序列中是否有p的一个循环排列. 思路:以p = [3, 1, 2]举例, 我们扫描数组b,假设当前数字是1,那么 ...
- Ajax01 什么是ajax、获取ajax对象、ajax对象的属性和方法、编程步骤、缓存问题、乱码问题
目录 1 什么是ajax 2 获取ajax对象 3 ajax对象的属性和方法 4 使用ajax的编程步骤 5 缓存问题 6 乱码问题 1 什么是ajax ajax是一种用来改善用户体验的技术,其本质是 ...
- php单引号双引号的区别
单引号里面的内容是直接被当做一个字符串,用双引号定义的字符串的内容最只要的特征就是会被解析.
- 怎么把网页保存为pdf文件
不就是用chrome浏览器打印功能,然后保存为pdf就可以了吗? 对于一些结构简单的比如,RFC文档这样操作一般没什么问题,对于一些有浮动元素的网页就不好说了,必须先用chrome的审查元素把一些不必 ...
- R: 基本的数学运算
################################################### 问题:基本数学运算 18.4.30 R语言用于初等数学的计算,都怎么表示??加减乘除.余数. ...