eolymp
bolt
Try our new interface for solving problems
Məsələlər

Filter & Perform

Filter & Perform

A data set in an input file contains several lines of data. The first line provides two information, the first is an integer between \textbf{1} to \textbf{5} (inclusive), which represents the number of subsequent lines in the data set and the second is any of the following symbols \textbf{\{+, -, ^\}}, which represents operation to be performed. The second line onwards has one data element each which can be of positive integer, positive real number or string (with maximum length of \textbf{10}). A program is to be written so that if the symbol in the first line is a '\textbf{+}', then only the lines containing integers in the data set will produce output. The output will be the sum of each digit in the integer data. On the other hand, if the symbol is a '\textbf{-}', then only the lines containing strings will produce output. The output will be the string with all character '\textbf{a}' (if any) being removed. If the symbol is a '\textbf{^}', then only the lines containing real numbers will produce output. The output will be the number in its exponential format. For example \textbf{2.53} will be represented as \textbf{2.53e0}, \textbf{25.533} will be \textbf{2.5533e1} and \textbf{0.253} will be \textbf{2.53e-1}. \InputFile The first line of the input data contains an integer which represents the number of test cases. The line is then followed by the data for each of the test cases. Each test case begins with a line containing two data, i.e., an integer \textbf{n }denoting the number of data lines (\textbf{1} ≤ \textbf{n} ≤ \textbf{5}) and a special symbol '\textbf{+}', '\textbf{-}', or '\textbf{^}' denoting operation to be performed. Each data line in the data set contains either a positive integer, a positive real number or a string with maximum size of \textbf{10}. \OutputFile The output comprises of one line for each test case. The line begins with prefix "\textbf{Case #x:}" where \textbf{x} represents the case number, followed by the output of the test case. Depending on the symbol provided in the first line of the test case, only data of applicable type will produce output with a space in between.
Zaman məhdudiyyəti 10 saniyə
Yaddaşı istafadə məhdudiyyəti 64 MiB
Giriş verilənləri #1
3
3 +
567
2.53
10
4 -
2.53abc
DAf
aag
123
3 ^
253.3
Def
0.00067
Çıxış verilənləri #1
Case #1: 18 1
Case #2: 2.53bc DAf g
Case #3: 2.533e2 6.7e-4
Mənbə ACM-ICPC Malaysia al-Khawārizmī National Programming Contest 2013 (al-Khawārizmī' 2013), 21-22 September 2013