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

水题之王,我无语了…… 考的其实是顺时针和逆时针转到下一个数的计算方法,俩种情况

Posted by custqi at 2010-11-11 10:48:40 on Problem 2304
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		
		Scanner in = new Scanner(System.in);
		while (true) {
			int begin = in.nextInt();
			int one = in.nextInt();
			int two = in.nextInt();
			int three = in.nextInt();
			if ((begin | one | two | three) == 0)
				break;
			int result = 1080;
			
			result += begin < one ? (begin + 40 - one) * 9 : (begin - one) * 9;
			
			result += one < two ? (two - one) * 9 : (40 + two - one) * 9;

			result += two < three ? (two + 40 - three) * 9 : (two - three) * 9;
			System.out.println(result);
		}
	}

}

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