【CODEFORCES】 A. Bayan Bus

A. Bayan Bus
time limit per test
2 seconds
memory limit per test
256 megabytes
input
standard input
output
standard output

The final round of Bayan Programming Contest will be held in Tehran, and the participants will be carried around with a yellow bus. The bus has 34 passenger seats: 4 seats in the last row and 3 seats in remaining rows.

The event coordinator has a list of k participants who should be picked up at the airport. When a participant gets on the bus, he will sit in the last row with an empty seat. If there is more than one empty seat in that row, he will take the leftmost one.

In order to keep track of the people who are on the bus, the event coordinator needs a figure showing which seats are going to be taken by k participants. Your task is to draw the figure representing occupied seats.

Input

The only line of input contains integer k(0 ≤ k ≤ 34), denoting the number of participants.

Output

Print the figure of a bus with k passengers as described in sample tests. Character '#' denotes an empty seat, while 'O' denotes a taken seat. 'D' is the bus driver and other characters in the output are for the purpose of beautifying the figure. Strictly follow the sample test cases output format. Print exactly six lines. Do not output extra space or other characters.

Sample test(s)
input
9
output
+------------------------+
|O.O.O.#.#.#.#.#.#.#.#.|D|)
|O.O.O.#.#.#.#.#.#.#.#.|.|
|O.......................|
|O.O.#.#.#.#.#.#.#.#.#.|.|)
+------------------------+
input
20
output
+------------------------+
|O.O.O.O.O.O.O.#.#.#.#.|D|)
|O.O.O.O.O.O.#.#.#.#.#.|.|
|O.......................|
|O.O.O.O.O.O.#.#.#.#.#.|.|)
+------------------------+

题解:简单模拟即可。(如果这也算题解的话...)

代码倒是写的有点长。

#include <iostream>

using namespace std;

int prin(int n)
{
    int i=n;
    while (i>0)
    {
        cout <<"O.";
        i--;
    }
    return 11-n;
}

void s_prin(int n)
{
    int i=n;
    while (i>0)
    {
        cout <<"#.";
        i--;
    }
}

int main()
{
    int k,n,m,b;
    cin >>k;
    //first line
    cout <<"+------------------------+"<<endl;
    if (k-4>0)
    {
        n=(k-4)%3;
        m=(k-4)/3;
    //second line
    cout <<"|";
    if (n)
    {
        b=prin(m+2);
        n--;
    }
    else b=prin(m+1);
    s_prin(b);
    cout <<"|D|)"<<endl;
    //third line
    cout <<"|";
    if (n)
    {
        b=prin(m+2);
        n--;
    }
    else b=prin(m+1);
    s_prin(b);
    cout <<"|.|"<<endl;
    // fourth line
    cout <<"|O.......................|"<<endl;
    // fivth line
    cout <<"|";
    b=prin(m+1);
    s_prin(b);
    cout <<"|.|)"<<endl;
    //the last
    cout <<"+------------------------+"<<endl;
    }
    else
    {
        //second line
        cout <<"|";
        if (k)
        {
             b=prin(1);
             s_prin(10); k--;
        }
        else  s_prin(11);
        cout <<"|D|)"<<endl;
        //third line
        cout <<"|";
        if (k)
        {
             b=prin(1);
             s_prin(10); k--;
        }
        else  s_prin(11);
        cout <<"|.|"<<endl;
        //fourth line
        if (k) { cout <<"|O.......................|"<<endl; k--; }
        else cout <<"|#.......................|"<<endl;
        //fivth line
        cout <<"|";
        if (k)
        {
             b=prin(1);
             s_prin(10); k--;
        }
        else s_prin(11);  cout <<"|.|)"<<endl;
        cout <<"+------------------------+"<<endl;
    }
    return 0;
}




### Codeforces Div.2 比赛难度介绍 Codeforces Div.2 比赛主要面向的是具有基础编程技能到中级平的选手。这类比赛通常吸引了大量来自全球不同背景的参赛者,包括大学生、高中生以及一些专业人士。 #### 参加资格 为了参加 Div.2 比赛,选手的评级应不超过 2099 分[^1]。这意味着该级别的竞赛适合那些已经掌握了一定算法知识并能熟练运用至少一种编程语言的人群参与挑战。 #### 题目设置 每场 Div.2 比赛一般会提供五至七道题目,在某些特殊情况下可能会多或少。这些题目按照预计解决难度递增排列: - **简单题(A, B 类型)**: 主要测试基本的数据结构操作和常见算法的应用能力;例如数组处理、字符串匹配等。 - **中等偏难题(C, D 类型)**: 开始涉及较为复杂的逻辑推理能力和特定领域内的高级技巧;比如图论中的最短路径计算或是动态规划入门应用实例。 - **高难度题(E及以上类型)**: 对于这些问题,则加侧重考察深入理解复杂概念的能力,并能够灵活组合多种方法来解决问题;这往往需要较强的创造力与丰富的实践经验支持。 对于新手来说,建议先专注于理解和练习前几类较容易的问题,随着经验积累和技术提升再逐步尝试高层次的任务。 ```cpp // 示例代码展示如何判断一个数是否为偶数 #include <iostream> using namespace std; bool is_even(int num){ return num % 2 == 0; } int main(){ int number = 4; // 测试数据 if(is_even(number)){ cout << "The given number is even."; }else{ cout << "The given number is odd."; } } ```
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值