Warm-Up round at Codingchillout.Malta http://codechillout.sphere-contest.com/round/test
http://codechillout.sphere-contest.com/problems/test/TEST
TEST
Your program is to use the brute-force approach in order to find the Answer to Life, the Universe, and Everything. More precisely… rewrite small numbers from input to output. Stop processing input after reading in the number 42. All numbers at input are integers of one or two digits.
Example
Input: 1 2 88 42 99 Output: 1 2 88
Answer
#include int main(void) { int i; while (scanf("%d", &i)==1){ if(i == 42) break; printf("%d\n",i); } return 0; }
http://codechillout.sphere-contest.com/problems/test/FCTRL2
Small factorials
You are asked to calculate factorials of some small positive integers.
Input
An integer t, 1<=t<=100, denoting the number of testcases, followed by t lines, each containing a single integer n, 1<=n<=100.
Output
For each integer n given at input, display a line with the value of n! (“n factorial”).
Example
Sample input:
4 1 2 5 3
Sample output:
1 2 120 6
Answer
import math n = int(raw_input()); for v in range(0,n): print math.factorial(int(raw_input()))
http://codechillout.sphere-contest.com/problems/test/ADDTWO
Add two number
Calculate the sum a+b for given integers a and b.
Input
There will be provided certain number of data sets for the problem. Each data set consist of two integer numbers ai and bi separated with a space, where i is the number of the data set. Data sets are separated with a new line.
Output
For ith data set print the value of ai + bi. Answers should be separated with a new line.
Example
Input: 2 3 10 -2 -1 5 -3 -3 0 1 Output: 5 8 4 -6 1
Answer
import fileinput for line in fileinput.input(): n = line.split(); print int(n[0]) + int(n[1])
http://codechillout.sphere-contest.com/problems/test/REVARR
Reverse array
For a given array reverse its order.
Input
In the first line there will be a number of the data sets t. In the next t lines data sets follows. Each data set is a line of numbers separated by spaces. First number ni is the length of the array. Next ni numbers are the values in array.
Output
For ith data set write values from array in reversed order. Numbers should be separated by spaces and answers for data sets should be separated by a new line.
Example
Input: 2 7 1 2 3 4 5 6 7 3 3 2 11 Output: 7 6 5 4 3 2 1 11 2 3
Answer
n = int(raw_input()) for v in range(0,n): j = raw_input().split(" ") del j[0] j = " ".join(reversed(j)) print j