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的时限又放宽了一些了,这下应该好多了

Posted by hawk at 2004-12-20 09:41:17 on Problem 1006
In Reply To:我都用人脑代替计算机算到这份上了怎么还超时?错在哪了?大虾帮我看看 Posted by:clark at 2004-12-19 22:52:10
> 用秦九韶定理硬算得。测试数据都对也不会超时。只有一个循环啊为什么会超时?
> import java.util.Scanner;
> public class Main {
> 	public static void main(String[] args) {
> 		Scanner cin = new Scanner(System.in);
> 		int p = cin.nextInt();
> 		int e = cin.nextInt();
> 		int i = cin.nextInt();
> 		int d = cin.nextInt();
> 		int c = 1;
> 		while(p != -1){
> 			int triple = (p*5544+e*14421+i*1288)%21252;
> 			triple-=d;
> 			if(triple <= 0)
> 				triple+=21252;
> 			System.out.println("Case "+ c++ +": the next triple peak occurs in " + triple + " days.");
> 			p = cin.nextInt();
> 			e = cin.nextInt();
> 			i = cin.nextInt();
> 			d = cin.nextInt();
> 		}
> 	}
> }

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