ACM (TJU) : 1939


package volume_X;

import java.util.Scanner;

public class Id_1939 {

/**
* @param args
*/
public static void main(String[] args) {

Scanner input = new Scanner (System.in);

int n = input.nextInt();
int a [] [] = new int [15] [2];

while ( n != -1 ) {

for ( int i = 0; i < n; i++ ) { a [i] [0] = input.nextInt(); a [i] [1] = input.nextInt(); } int speed = a [0] [0] * a [0] [1]; for ( int i = 1; i < n; i++ ) speed += ( a [i] [0] * (a [i] [1] - a [i - 1] [1])); System.out.printf ("%d miles\n", speed); n = input.nextInt(); } } } [/sourcecode]

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s