Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

Java写的,case 都过了一直WA,求大神帮帮忙!(大家讨论的很强case也能过)

Posted by bbbqse at 2017-12-06 13:57:52 on Problem 1008
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.util.Scanner;

public class Main {

	static String[] haab = { "pop", "no", "zip", "zotz", "tzec", "xul",
			"yoxkin", "mol", "chen", "yax", "zac", "ceh", "mac", "kankin",
			"muan", "pax", "koyab", "cumhu", "uayet" };

	static String[] Tzolkin = { "imix", "ik", "akbal", "kan", "chicchan",
			"cimi", "manik", "lamat", "muluk", "ok", "chuen", "eb", "ben",
			"ix", "men", "cib", "caban", "eznab", "canac", "ahau" };

	public static void main(String[] args) throws FileNotFoundException {
		// TODO Auto-generated method stub
		System.setIn(new FileInputStream("input.txt"));
		Scanner scan = new Scanner(System.in);

		int N = scan.nextInt();
		System.out.println(N);

		for (int i = 0; i < N; i++) {
			String s = scan.next().replace(".", "");
			int data = Integer.parseInt(s);
			String month = scan.next();
			int year = scan.nextInt();

			int sum = haab(data, month, year);

			toTzolkim(sum);

		}
	}

	private static void toTzolkim(int sum) {
		// TODO Auto-generated method stub
		int year = sum / 260;
		int m = sum % 20;
		String month = Tzolkin[m];
		int day = sum % 13 + 1;

		System.out.println(day + " " + month + " " + year);

	}

	private static int haab(int data, String month, int year) {
		// TODO Auto-generated method stub
		int m = 0;
		for (int i = 0; i < 19; i++) {
			if (month.equals(haab[i])) {
				m = 20 * i;
			}
		}

		return data + m + 365 * year;
	}
}  

Followed by:

Post your reply here:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator