eolymp
bolt
Try our new interface for solving problems
Problems

Java Certification

Java Certification

You have just completed Java Certification exam that contained \textit{n }questions. You have a score card that explains your performance. The example of the scorecard is given below. You have correctly answered 78 questions out of 87. From this scorecard you can infer that the questions are broken down into \textit{m }categories (in the above example \textit{m }= 6). Each category contains \textit{n_i }questions (1 ≤\textit{ ni ≤ n}), so that ∑_1_\{≤\}\textit{_i_\{≤\}_m n_i }= \textit{n}. You know that you have correctly answered \textit{k }questions out of \textit{n }(in the above example \textit{k }= 78 and \textit{n }= 87), so you can easily find the number of incorrect answers \textit{w }= \textit{n - k }(in the above example \textit{w }= 9). You do remember several questions that you were unsure about and you can guess what category they belong to. To figure out if your answers on those questions were right or wrong, you really want to know how many incorrect answers you have given in each category. Let \textit{w_i }(0 ≤\textit{ w_i ≤ n_i}) be the number of \textit{incorrect }answers in \textit{i}-th category, ∑_1_\{≤\}\textit{_i_\{≤\}_m w_i }= \textit{w}. From the scorecard you know the \textit{percentage of correct answers }in each category. That is, for each \textit{i }from 1 to \textit{m }you know the value of 100(\textit{n_i - w_i})/\textit{ni }rounded to the nearest integer. The value with a fractional part of 0.5 is rounded to the nearest even integer. It may not be possible to uniquely find the valid values for \textit{w_i}. However, you guess that the questions are broken down into categories in a mostly uniform manner. You have to find the valid values of \textit{w_i }and \textit{n_i}, so that to minimize the difference between the maximum value of \textit{n_i }and the minimum value of \textit{n_i}. If there are still multiple possible values for \textit{w_i }and \textit{n_i}, then find any of them. \InputFile The first line of the input file contains three integer numbers -- \textit{k}, \textit{n}, and \textit{m}, where \textit{k }(0 ≤\textit{ k ≤ n}) is the number of correctly answered questions, \textit{n }(1 ≤\textit{ n ≤ }100) is the total number of questions, \textit{m }(1 ≤\textit{ m ≤ }10) is the number of question categories. The following \textit{m }lines of the input file contain one integer number from 0 to 100 (inclusive) on a line -- percentages of the number of the correct answers in each category. The input file always corresponds to some valid set of \textit{w_i }and \textit{n_i}. \OutputFile Write to the output file \textit{m }lines with two integer numbers \textit{w_i }and \textit{n_i }on a line, separated by a space -- the number of incorrect answers and the total number of questions in each category, satisfying constraints as given in the problem statement.
Time limit 1 second
Memory limit 64 MiB
Input example #1
78 87 6
100
100
83
92
75
93
Output example #1
0 13
0 13
3 18
1 13
4 16
1 14
Author Roman Elizarov