#B3704. Multi-Task: Basic Operations

    ID: 11363 Type: Default 1000ms 256MiB

Multi-Task: Basic Operations

Multi-Task: Basic Operations

This problem consists of three independent tasks. The first line of the input contains a task indicator (an integer 1, 2, or 3) that determines which task to execute:

  • Task 1: Given two integers \(a\) and \(b\), compute \(a + b\).
  • Task 2: Given a string \(s\) consisting only of lowercase letters, count and output the number of occurrences of the letter a.
  • Task 3: Given an integer \(n\) followed by an array \(a_0, a_1, \dots, a_{n-1}\) (0-indexed), construct an array \(b\) such that \[ b_i = a_{(i+1) \bmod n} - a_i \quad \text{for} \; 0 \leq i < n, \] and output the array \(b\) (with values separated by a single space).

Based on the task indicator, the input format will vary accordingly. Write a program that reads the input and performs the operation corresponding to the specified task.

inputFormat

The input begins with a single integer that indicates the problem number:

  • If the number is 1: The next line contains two space-separated integers \(a\) and \(b\).
  • If the number is 2: The next line contains a string \(s\) consisting only of lowercase letters.
  • If the number is 3: The next line contains an integer \(n\) (the length of the array), followed by a line containing \(n\) space-separated integers representing the array \(a_0, a_1, \dots, a_{n-1}\).

outputFormat

Output the result corresponding to the chosen task:

  • For Task 1 and Task 2, output a single integer.
  • For Task 3, output \(n\) integers separated by a space representing the array \(b\).

sample

1
3 4
7