fork(1) download
  1. #include <iostream>
  2.  
  3. struct DirectionalForm{
  4. double a;
  5. double b;
  6. };
  7.  
  8. DirectionalForm getDirectionalForm(double x[], double y[]);
  9. bool isSameLine(DirectionalForm dirFor, double x, double y);
  10.  
  11. int main(){
  12. int t;
  13. std::cin>>t;
  14.  
  15. for(int i=0; i<t; i++){
  16. double x[3];
  17. double y[3];
  18.  
  19. for(int i=0; i<3; i++){
  20. std::cin>>x[i]>>y[i];
  21. }
  22.  
  23. auto dirFor = getDirectionalForm(x,y);
  24.  
  25. //std::cout<<"y = "<<dirFor.a<<"x + "<<dirFor.b<<std::endl;
  26.  
  27. if(isSameLine(dirFor,x[2],y[2]))
  28. std::cout<<"TAK"<<std::endl;
  29. else
  30. std::cout<<"NIE"<<std::endl;
  31. }
  32. }
  33.  
  34. DirectionalForm getDirectionalForm(double x[], double y[]){
  35. DirectionalForm toRet;
  36. double divSub;
  37.  
  38. if(y[0]-y[1] == 0 || x[0]-x[1] == 0) divSub = 0;
  39. else divSub = (y[0]-y[1])/(x[0]-x[1]);
  40. toRet.a = divSub;
  41. toRet.b = y[0]-divSub*x[0];
  42. return toRet;
  43. }
  44.  
  45. bool isSameLine(DirectionalForm dirFor, double x, double y){
  46. return (dirFor.a*x + dirFor.b == y) ? true : false;
  47. }
Success #stdin #stdout 0s 4176KB
stdin
5
1	2	3	4	5	6
1	3	1	4	1	-3
1	2	-3	4	3	9
2	-1	3	-1	-4	-1
0	0	0	0	0 	0
stdout
TAK
NIE
NIE
TAK
TAK