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 |
为什么会RunTimeError啊?难道判断文件结束有问题?import java.io.*; import java.math.BigDecimal; import java.util.StringTokenizer; public class Main { public static void main(String args[]) throws Exception { String s; BigDecimal m,n,t; int i,j,k; BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); System.out.flush(); s = br.readLine(); while(s!=null) { StringTokenizer a = new StringTokenizer(s); s = a.nextToken(); m = new BigDecimal(s); k = Integer.parseInt(s); i = Integer.parseInt(a.nextToken()); j = Integer.parseInt(a.nextToken()); System.out.print("("+m+"^"+i+"-1)/("+m+"^"+j+"-1) "); if((i-j)*Math.log(k)/Math.log(10)<102) { n = m.pow(i).subtract(new BigDecimal("1")); t = m.pow(j).subtract(new BigDecimal("1")); m = n.divide(t,0); if(m.multiply(t).equals(n)) { if(m.toPlainString().length()>=100) System.out.println("is not an integer with less than 100 digits."); else System.out.println(m); } else System.out.println("is not an integer with less than 100 digits."); } else System.out.println("is not an integer with less than 100 digits."); System.out.flush(); s = br.readLine(); } } } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator