import java.io.PrintStream; import java.util.ArrayList; import java.util.Arrays; import java.util.List; import java.util.Scanner; /** * Solution to Simple Cron Spec. * * @author vanb */ public class cron_vanb { /** Input. */ private static Scanner sc; /** Output. */ private static PrintStream ps; /** * Parses a spec, returning a list of all the (hours | minutes | seconds) specified. * * @param spec the spec * @param max the max (24 for hours, 60 for minutes or seconds) * @return the list */ private List parse( String spec, int max ) { List result = new ArrayList(max); if( spec.contains( "*" ) ) { for( int i=0; i0 ) { List hours = parse( sc.next(), 24); List minutes = parse( sc.next(), 60 ); List seconds = parse( sc.next(), 60 ); totalJobs += hours.size()*minutes.size()*seconds.size(); for( int h : hours ) for( int m : minutes ) for( int s : seconds ) times[h][m][s] = true; } int totalSeconds = 0; for( boolean[][] h : times ) for( boolean[] m : h ) for( boolean s : m ) if( s ) ++totalSeconds; ps.println( totalSeconds + " " + totalJobs ); } /** * Main. * * @param args unused * @throws Exception the exception */ public static void main( String[] args ) throws Exception { sc = new Scanner( System.in ); ps = System.out; new cron_vanb().doit(); } }