No.112 Confusing Crane-and-Turtle Problem
Problem Statement
There are $N$ animals.
The animals are numbered from $1$ to $N$.
Each animal is either a crane or a turtle.
As you know, a crane has $2$ legs and a turtle has $4$ legs.
One day, the animals decided to study crane-and-turtle arithmetic.
To begin, each animal individually counted "the total number of legs of everyone."
However, being careless, all of the animals forgot to count their own legs.
Your task is to determine the number of cranes and the number of turtles from these counts.
Input
$N$ $a_1$ $a_2$ $\ldots$ $a_N$
Line $1$ gives the number of animals $N(2\leq N\leq50)$.
Line $2$ gives, separated by spaces, the total number of legs $a_i$ counted by the $i$-th animal.
$a_i$ are values that satisfy the problem's constraints.
Output
Output the number of cranes and the number of turtles, in this order, separated by a space.
It is guaranteed that exactly one solution exists.
Print a newline at the end.
Sample
Sample 1
Input
2 2 4
Output
1 1
Animal number $1$ is a turtle, and animal number $2$ is a crane.
Sample 2
Input
3 4 4 4
Output
3 0
All $3$ animals are cranes.
提出するには、Twitter 、GitHub、 Googleもしくは右上の雲マークをクリックしてアカウントを作成してください。
sugim48