#P5719. Averaging Divisible and Non-Divisible Numbers
Averaging Divisible and Non-Divisible Numbers
Averaging Divisible and Non-Divisible Numbers
Given two positive integers n and k, consider all integers from 1 to n. These numbers are divided into two groups:
- Group A: numbers that are divisible by k (i.e. multiples of k).
- Group B: numbers that are not divisible by k.
It is guaranteed that both groups contain at least one number. Your task is to compute the arithmetic mean of each group. The result should be printed with exactly one digit after the decimal point, and the two averages should be separated by a space.
Formally, let \( A = \{ x \mid 1 \le x \le n,\; k \mid x \} \) and \( B = \{ x \mid 1 \le x \le n,\; k \nmid x \} \). Compute:
\[ \text{average}_A = \frac{\sum_{x \in A} x}{|A|}, \quad \text{average}_B = \frac{\sum_{x \in B} x}{|B|} \]and output them in the format:
average_A average_B
inputFormat
The input consists of two positive integers n and k on a single line, separated by a space. You may assume that 1 ≤ k ≤ n and that both groups have at least one number.
outputFormat
Output two numbers: the average of Group A (numbers divisible by k) and the average of Group B (numbers not divisible by k). Each number should be printed with exactly one decimal place, and the two numbers should be separated by a single space.
sample
10 2
6.0 5.0