package net.ipipip0129.yukicoder.no667; import java.util.Arrays; import java.util.List; import java.util.Scanner; import java.util.stream.Collectors; public class Main { public static void main(String[] args) { Scanner scan = new Scanner(System.in); List boxlist = Arrays.asList(scan.nextLine().split("")); // Stream API 使用 /**int passCount = boxlist.stream() .filter(s -> s.startsWith("o")) .collect(Collectors.toList()) .size(); int trapCount = boxlist.stream() .filter(s -> s.startsWith("x")) .collect(Collectors.toList()) .size();**/ // Stream API 未使用 int passCount = 0; int trapCount = 0; for (String box : boxlist) { switch (box.charAt(0)) { case 'o': passCount++; break; case 'x': trapCount++; break; } } for (String box : boxlist) { System.out.println(((double) passCount / (double) (passCount + trapCount)) * 100); switch (box.charAt(0)) { case 'o': passCount--; break; case 'x': trapCount--; break; } } } }