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 |
Help me please... Runtime ErrorHi, I tried to do this problem, but I always got Runtime Error. I don't know why, because I think my code is correct... Please help me... Here is my code: import java.io.*; import java.util.*; class Main { static long x[]; static long y[]; public static int count(long mx, long my, int index) { int cont = 0; for (int i = 0; i < x.length; i ++) if (my * (x[index] - x[i]) == mx * (y[index] - y[i])) cont ++; return cont; } public static void main(String args[]) throws IOException { BufferedReader in = new BufferedReader(new InputStreamReader(System.in)); StringTokenizer token; int casos = Integer.parseInt(in.readLine()); x = new long[casos]; y = new long[casos]; for (int i = 0; i < casos; i ++) { token = new StringTokenizer(in.readLine()); x[i] = Long.parseLong(token.nextToken()); y[i] = Long.parseLong(token.nextToken()); } int max = 1; for (int i = 0; i < casos - 1; i ++) { for (int j = i + 1; j < casos; j ++) { long mx = x[i] - x[j]; long my = y[i] - y[j]; int tmp = count(mx, my, i); if (tmp > max) max = tmp; } } System.out.println(max); } } Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator