Rezultati

Up. imeNalogaJezikRezultatČas oddaje
scnm1-2018 Fruit Ninja Java 100/100OK 13. okt '18 @ 12:12

Test Točke Porabljen spomin Porabljen čas Status
#1 11/11 34,707 MiB 0,000 s OK
#2 11/11 33,141 MiB 0,000 s OK
#3 11/11 33,129 MiB 0,000 s OK
#4 11/11 36,633 MiB 0,000 s OK
#5 11/11 36,992 MiB 0,000 s OK
#6 11/11 39,707 MiB 0,000 s OK
#7 11/11 40,082 MiB 0,000 s OK
#8 11/11 39,434 MiB 0,000 s OK
#9 12/12 38,621 MiB 0,000 s OK

Ocenjevani program (n1.java):
import java.util.*;
import java.io.*;

public class n1 {
	public static void main(String[] args) throws Exception {
		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer st = new StringTokenizer(in.readLine());
		int x1 = Integer.parseInt(st.nextToken());
		int y1 = Integer.parseInt(st.nextToken());
		int x2 = Integer.parseInt(st.nextToken());
		int y2 = Integer.parseInt(st.nextToken());
		int mx=Math.min(x1,x2);
		int Mx=Math.max(x1,x2);
		int my=Math.min(y1,y2);
		int My=Math.max(y1,y2);
		long a=y1-y2;
		long b=x2-x1;
		long c=y1*(x1-x2)+x1*(y2-y1);
		//System.out.println(a+" "+b+" "+c);
		int n=Integer.parseInt(in.readLine());
		int count=0;
		for(int i=0;i<n;i++) {
			//System.out.println(i);
			st=new StringTokenizer(in.readLine());
			long x=Integer.parseInt(st.nextToken());
			long y=Integer.parseInt(st.nextToken());
			long r=Integer.parseInt(st.nextToken());
			if((y-y1)*(y2-y1)>(x-x1)*(x1-x2)!=(y-y2)*(y2-y1)>(x-x2)*(x1-x2)) { 
				//System.out.println("Je v pravem obmocju");
				double dist=Math.abs(a*x+b*y+c)/(Math.sqrt(a*a+b*b));
				if((a*a+b*b)*r*r>=(a*x+b*y+c)*(a*x+b*y+c)) {
					count++;
					//System.out.println("zadeli smo "+i+" zaradi premice");
				}
			}else {
				if(r*r>=(x-x1)*(x-x1)+(y-y1)*(y-y1)) {
					count++;
					//System.out.println("zadeli smo "+i+" zaradi t1");
				}else if(r*r>=(x-x2)*(x-x2)+(y-y2)*(y-y2)) {
					count++;
					//System.out.println("zadeli smo "+i+" zaradi t2");
				}
			}
		}
		System.out.println(count);
	}
}