// UVa 11947 - Cancer or Scorpio import java.util.Calendar; import java.util.GregorianCalendar; import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner scan = new Scanner(System.in); int cases = scan.nextInt(); scan.nextLine(); GregorianCalendar cal = new GregorianCalendar(); for (int c = 1; c <= cases; c++) { // get date String l = scan.nextLine(); int m = (l.charAt(0) - '0') * 10 + (l.charAt(1) - '0') - 1; int d = (l.charAt(2) - '0') * 10 + (l.charAt(3) - '0'); int y = (l.charAt(4) - '0') * 1000 + (l.charAt(5) - '0') * 100 + (l.charAt(6) - '0') * 10 + (l.charAt(7) - '0'); cal.set(Calendar.MONTH, m); cal.set(Calendar.DATE, d); cal.set(Calendar.YEAR, y); // add gestation period cal.add(Calendar.DATE, 40 * 7); // get new date m = cal.get(Calendar.MONTH); d = cal.get(Calendar.DATE); y = cal.get(Calendar.YEAR); // get sign String sign = "capricorn"; if (cal.compareTo(new GregorianCalendar(y, 0, 21)) >= 0) sign = "aquarius"; if (cal.compareTo(new GregorianCalendar(y, 1, 20)) >= 0) sign = "pisces"; if (cal.compareTo(new GregorianCalendar(y, 2, 21)) >= 0) sign = "aries"; if (cal.compareTo(new GregorianCalendar(y, 3, 21)) >= 0) sign = "taurus"; if (cal.compareTo(new GregorianCalendar(y, 4, 22)) >= 0) sign = "gemini"; if (cal.compareTo(new GregorianCalendar(y, 5, 22)) >= 0) sign = "cancer"; if (cal.compareTo(new GregorianCalendar(y, 6, 23)) >= 0) sign = "leo"; if (cal.compareTo(new GregorianCalendar(y, 7, 22)) >= 0) sign = "virgo"; if (cal.compareTo(new GregorianCalendar(y, 8, 24)) >= 0) sign = "libra"; if (cal.compareTo(new GregorianCalendar(y, 9, 24)) >= 0) sign = "scorpio"; if (cal.compareTo(new GregorianCalendar(y, 10, 23)) >= 0) sign = "sagittarius"; if (cal.compareTo(new GregorianCalendar(y, 11, 23)) >= 0) sign = "capricorn"; // print output System.out.printf("%d %02d/%02d/%04d %s\n", c, m + 1, d, y, sign); } } }
Monday, July 25, 2016
UVa 11947 - Cancer or Scorpio
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment