Problem: Seating Arrangement

P

Two friends are quite fond of travelling. They mostly travel by railways. They were travelling in a train one day and they got interested in the seating arrangement of their compartment. The compartment looked something like

So they got interested to know the seat number facing them and the seat type facing them. The seats are denoted as follows :

  • Window Seat : WS
  • Middle Seat : MS
  • Aisle Seat : AS

You will be given a seat number, find out the seat number facing you and the seat type, i.e. WSMS or AS.

INPUT
First line of input will consist of a single integer T denoting number of test-cases. Each test-case consists of a single integer N denoting the seat-number.

OUTPUT
For each test case, print the facing seat-number and the seat-type, separated by a single space in a new line.

CONSTRAINTS

  • 1<=T<=105
  • 1<=N<=108
SAMPLE INPUTSAMPLE OUTPUT
2
18
40
19 WS
45 AS
#include <stdio.h>

int main()
{
    int test_cases,current_seat,opposite_seat;
    scanf("%d", &test_cases);

    for(int i=0;i<test_cases;i++)
    {
        scanf("%d",&current_seat);

        int bank =  (current_seat-1)/12;
        int bank_seat =  current_seat - bank*12;
        opposite_seat = bank*12 + (13-bank_seat);

        printf("%d",opposite_seat);

        switch(bank_seat)
        {
            case 1:
            case 6:
            case 7:
            case 12:
                printf(" WS\n");
                break;
            case 2:
            case 5:
            case 8:
            case 11:
                printf(" MS\n");
                break;
            default:
                printf(" AS\n");
                break;          
        }

    }
    return 0;
}
Disclaimer: The present content may not be used for training artificial intelligence or machine learning algorithms. All other uses, including search, entertainment, and commercial use, are permitted.

Categories

Tags