zoukankan      html  css  js  c++  java
  • 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.

    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
    首先最左边是一个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;
    }
    

      

    
    


  • 相关阅读:
    sql server 获取本月的始末时间
    超时时间已到
    sql server定时自动备份
    创建连接服务器
    date制作电子时钟
    C#继承(三)
    C# Split分割
    Dom动态添加属性
    date制作电子时钟(二)
    全局遮罩 shade
  • 原文地址:https://www.cnblogs.com/yinghualuowu/p/5380455.html
Copyright © 2011-2022 走看看