import java.util.ArrayList; import java.util.Scanner; public class Wheels { Wheel[] wheels; // storing all the // alternative way public class Wheel{ int x,y,radius; int p=0,q; //int index; // the index of the wheels adjacent to it? boolean isClock; boolean visited; ArrayList adj; // store the wheels adjacent to it public Wheel(int nx,int ny, int nr){ x=nx; y=ny; radius = nr; visited = false; } } public boolean isTangent(Wheel w1,Wheel w2){ int r1,r2,d; r1 = w1.radius; r2 = w2.radius; d = (int) (Math.pow((w1.x-w2.x),2)+Math.pow((w1.y-w2.y),2)); int sum = (int) (Math.pow(r1+r2,2)); /*System.out.println(d); System.out.println(sum); System.out.println("-------");*/ return d==sum; } // then run bfs starting at first, every adjacent wheel has the !isClock of previous one and public void bfs(Wheel w){ if(!w.visited){ w.visited = true; for(Wheel temp:w.adj){ temp.isClock = !w.isClock; temp.p = w.radius*w.p; temp.q = temp.radius*w.q; int gcd = gcd(temp.p,temp.q); temp.p = temp.p/gcd; temp.q = temp.q/gcd; /* * */ //System.out.println("p is: "+temp.p); //System.out.println("q is: "+ temp.q); bfs(temp); } } } //String gcd() public int gcd(int a, int b){ if(b!=0){ int temp = b; b = a%b; a = temp; return gcd(a,b); } return a; } public String speed(int a, int b){ if(gcd(a,b)==b){ b = a/b; return Integer.toString(b); }else if(gcd(a,b)==a){ //a = (a/a)/(b/a); return "1/"+Integer.toString(b/a); }else{ int temp = gcd(a,b); a = a/temp; b = b/temp; String s = Integer.toString(a)+"/"+Integer.toString(b); return s; } } //bfs queue // hashcode - the order of the circle public void solve(){ Scanner in = new Scanner(System.in); int cases = in.nextInt(); int i=0; //for(int i=0;i temp1 = new ArrayList(); for(int k=0;k