Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.io.*;
- import java.math.*;
- import java.security.*;
- import java.text.*;
- import java.util.*;
- import java.util.concurrent.*;
- import java.util.regex.*;
- import java.util.function.IntConsumer;
- import java.util.stream.IntStream;
- public class Solution {
- // Complete the plusMinus function below.
- static void plusMinus(int[] arr) {
- IntStream.of(arr).collect(DangStatisTic::new, DangStatisTic::accept, (a, b) -> {
- throw new UnsupportedOperationException();
- }).print();
- }
- private static final Scanner scanner = new Scanner(System.in);
- public static void main(String[] args) {
- int n = scanner.nextInt();
- scanner.skip("(\r\n|[\n\r\u2028\u2029\u0085])?");
- int[] arr = new int[n];
- String[] arrItems = scanner.nextLine().split(" ");
- scanner.skip("(\r\n|[\n\r\u2028\u2029\u0085])?");
- for (int i = 0; i < n; i++) {
- int arrItem = Integer.parseInt(arrItems[i]);
- arr[i] = arrItem;
- }
- plusMinus(arr);
- scanner.close();
- }
- }
- class DangStatisTic implements IntConsumer {
- int biggerThan0;
- int lessThan0;
- int is0;
- int size;
- public DangStatisTic() {}
- public void print() {
- System.out.println(String.format("%.6f", (float) biggerThan0 / ((float) size)));
- System.out.println(String.format("%.6f", (float) lessThan0 / ((float) size)));
- System.out.println(String.format("%.6f", (float) is0 / ((float) size)));
- }
- @Override
- public void accept(int value) {
- if (value > 0) biggerThan0++;
- if (value < 0) lessThan0++;
- if (value == 0) is0++;
- size++;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement