fork(2) download
  1. import java.io.BufferedReader;
  2. import java.io.IOException;
  3. import java.io.InputStreamReader;
  4. import java.io.PrintWriter;
  5.  
  6. public class Main {
  7.  
  8. public static void main(String[] args) throws IOException {
  9. PrintWriter write = new PrintWriter(System.out);
  10. int a,b,c,d;
  11. int liczbaTest = Integer.parseInt(read.readLine());
  12. double rownanie;
  13. for(int i = 0; i<liczbaTest; i++){
  14. String[] pk = read.readLine().split(" ");
  15. a=Integer.parseInt(pk[0]);
  16. b=Integer.parseInt(pk[1]);
  17. c=Integer.parseInt(pk[2]);
  18. d=Integer.parseInt(pk[3]);
  19.  
  20. if(a>b){
  21. a=b;
  22. b=Integer.parseInt(pk[0]);
  23. }
  24. if(c>d){
  25. c=d;
  26. d=Integer.parseInt(pk[2]);
  27. }
  28. if(c+d>a+b){
  29. write.println("NIE");
  30.  
  31. } else if(c*d>a*b){
  32. write.println("NIE");
  33.  
  34. } else if((c*c+d*d)>(a*a+b*b)){
  35. write.println("NIE");
  36.  
  37. } else if ((c<a)&&(d<b)) {
  38. write.println("TAK");
  39.  
  40. } else if ((d>b)&&(d*d<(a*a+b*b))) {
  41. rownanie=((2*c*d*b)+(d*d-c*c)*Math.sqrt(d*d+c*c-b*b))/(d*d+c*c);
  42. if(a>(rownanie)){
  43. write.println("TAK");
  44.  
  45. } else {
  46. write.println("NIE");
  47.  
  48. }
  49. }
  50. write.flush();
  51. }
  52. }
  53. }
Success #stdin #stdout 0.04s 4386816KB
stdin
2
100 50 105 9
100 50 105 10
stdout
TAK
NIE