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.
The only line of input contains integer k, (0 ≤ k ≤ 34), denoting the number of participants.
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.
9
+------------------------+ |O.O.O.#.#.#.#.#.#.#.#.|D|) |O.O.O.#.#.#.#.#.#.#.#.|.| |O.......................| |O.O.#.#.#.#.#.#.#.#.#.|.|) +------------------------+
20
+------------------------+ |O.O.O.O.O.O.O.#.#.#.#.|D|) |O.O.O.O.O.O.#.#.#.#.#.|.| |O.......................| |O.O.O.O.O.O.#.#.#.#.#.|.|) +------------------------+
超水题,但是注意一个hack,导致我wa了6发
当k<=2的时候,那个位置注意了不是..而是#.
题目意思说#才表示一个空位置
#include<stdio.h> #include<string.h> #include<math.h> #include<iostream> #include<algorithm> #include<vector> #include<queue> #include<set> #include<map> #define INF 0x3fffffff #define eps 1e-6 #define pb push_back #define pf printf #define sf scanf #define si(n) sf("%d",&n) #define pi(n) pf("%d\n",n) #define ms memset #define bk break #define rt return #define ct continue #define LL long long #define REP0(i,n) for(i=0;i<(n);i++) #define REP1(i,n) for(i=1;i<=(n);i++) #define REP(i,s,n) for(i=(s);i<=(n);i++) #define mp(x,y) make_pair((x),(y)) #define maxn 1010 #define MOD #define db double #define op operator #define PI acos(-1) using namespace std; char tmp1[10]="|D|)"; char tmp2[10]="|.|"; char tmp3[10]="..|"; char tmp4[10]="|.|)"; void out(int a,int b,int c,int d){ // cout<<a<<b<<c<<d<<endl; char s[100]; puts("+------------------------+"); int i; for(i=0;i<a*2;){ s[i++]='O'; s[i++]='.'; } for(i=a*2;i<22;){ s[i++]='#'; s[i++]='.'; } s[i++]='\0'; pf("|%s%s\n",s,tmp1); for(i=0;i<b*2;){ s[i++]='O'; s[i++]='.'; } for(i=b*2;i<22;){ s[i++]='#'; s[i++]='.'; } s[i++]='\0'; pf("|%s%s\n",s,tmp2); for(i=0;i<c*2;){ s[i++]='O'; s[i++]='.'; } for(i=c*2;i<22;){ if(i==0){ s[i++]='#'; s[i++]='.'; } else{ s[i++]='.'; s[i++]='.'; } } s[i++]='\0'; pf("|%s%s\n",s,tmp3); for(i=0;i<d*2;){ s[i++]='O'; s[i++]='.'; } for(i=d*2;i<22;){ s[i++]='#'; s[i++]='.'; } s[i++]='\0'; pf("|%s%s\n",s,tmp4); puts("+------------------------+"); } int main(){ #ifdef ACBang // freopen("in.txt","r",stdin); // freopen("o2.txt","w",stdout); #endif int k; while(~sf("%d",&k)){ int a,b,c,d; if(k<0||k>34){ a=b=c=d=0; } else if(k<=4){ a=(k-1>=0)?1:0;k--; b=(k-1>=0)?1:0;k--; c=(k-1>=0)?1:0;k--; d=(k-1>=0)?1:0;k--; } else { k--; c=1; a=b=d=0; while(k>0){ a+=(k-1>=0)?1:0;k--; b+=(k-1>=0)?1:0;k--; d+=(k-1>=0)?1:0;k--; } } out(a,b,c,d); } rt 0; }