Online Judge | Problem Set | Authors | Online Contests | User | ||||||
---|---|---|---|---|---|---|---|---|---|---|
Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest |
把scanner改为原来的输入方法试试看,如果还不行,那就是算法问题了,而不是java的问题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: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator