Facebook Google Plus YouTube

URI Problem (Left Area) 1189:
Left Area is a basic problem on URI online judge for novice problem solver.
You can find details on this Link.

import java.util.Scanner;

/**
 * @Author : Muhammad Harun-Or-Roshid
 * @Date : Oct 28, 2016
 * @Time : 3:57:00 PM
 */
public class Uri1189 {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        double m[][] = new double[12][12];
        double sum = 0;
        int count = 0;
        String v = sc.next();
        for (int i = 0; i < m.length; i++) {
            for (int j = 0; j < m.length; j++) {
                double x = sc.nextDouble();
                m[i][j] = x;
                if (j < m.length - i - 1 && i > j) {
                    sum += x;
                    count++;
                }
            }

        }
        if (v.equals("S")) {
            System.out.printf("%.1f\n", sum);
        } else {
            System.out.printf("%.1f\n", (sum / count));
        }
    }
}

Leave a Reply

%d bloggers like this: