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 AC代码。。

Posted by winned at 2013-05-13 23:37:37 on Problem 1047
import java.awt.List;
import java.math.BigInteger;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		while (scanner.hasNext()) {
			int i;
			String input = scanner.nextLine();
			int length = input.length();
			List list = new List();
			String temp = input;
			for (i = 0; i < length - 1; i++) {
				temp = temp.substring(1) + temp.charAt(0);
				list.add(temp);
			}
			BigInteger bigInteger = new BigInteger(input);
			for (i = 2; i <= length; i++) {
				temp = bigInteger.multiply(new BigInteger(String.valueOf(i))).toString();
				while (temp.length() < length) {
					temp = '0' + temp;
				}
				boolean ok = false;
				for (int j = 0; j < list.getItemCount(); j++) {
					if (temp.equals(list.getItem(j))) {
						list.remove(j);
						ok = true;
						break;
					}
				}
				if (ok == false) {
					break;
				}
			}
			if (i > length) {
				System.out.println(input + " is cyclic");
			} else {
				System.out.println(input + " is not cyclic");
			}
		}
	}
}

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