jueves, 21 de junio de 2012

Duda libreria iostream

Hola,

que saben acerca del uso de la libreria iostream?
del hecho de que deba ponerse.h o no para declarla?
que se deba poner using namespace std; o std:: antes de cada objeto o funcion?

Yo intente usar << de cout, sin poner using namespace std; y no lo compilaba bien codeblocks

lunes, 18 de junio de 2012

Problema de esta semana: COJ 1500 an express taxi

Descripción

In a long street the traffic of express taxies is organized in the following way: There is a taxi stop every one kilometer. An express taxi drives along the street from each stop 1, 2, 3, ... or 10 kilometers without a stop. For each of the ten distances a separate price is fixed and marked in the table, e.g. 1 12 2 21 3 31 4 40 5 49 6 58 7 69 8 79 9 90 10 101 A passenger wants to travel n (1 <= n <= 100) kilometers. Can you write a program to helping on that. Which driving distances does the passenger have to choose so that the journey would be the cheapest, and what is the total price of the journey.

Especificación de entrada

The input has two lines. The first line contains ten space separated integer numbers which are prices for driving 1, 2, 3, ... , 10 kilometers. The last line contains the number of kilometers (n) which the passenger has to travel.

Especificación de salida

Each line except the last one should contain two numbers which are the length of the route and the price of the ticket. The total price of the journey should be written in the last line of the output. If several solutions are possible, choose one of them where tickets (in ascending ordered by the distance) are minimum.

Ejemplo de entrada

12 21 31 40 49 58 69 79 90 101
15

Ejemplo de salida

3 31
6 58
6 58
147