Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- using namespace std;
- int dotProduct(int vect_A[], int vect_B[])
- {
- int product = 0;
- for (int i = 0; i < 3; i++)
- product = product + vect_A[i] * vect_B[i];
- return product;
- }
- double get_norm (int vetor[])
- {
- double norm=0;
- for (int i = 0; i<3; i++)
- norm = norm + vetor[i]*vetor[i];
- norm = sqrt(norm);
- return norm;
- }
- int main (){
- int t, pos_ini1[3], pos_ini2[3], acele1[3], acele2[3], dif_pos[3], dif_ace[3], r1, r2, resposta[10010];
- double norm_a, prod_int, delta, norm_r;
- cin>>t;
- for (int i = 0; i<t; i++)
- {
- cin>>r1;
- cin>>r2;
- for(int j = 0; j<3;j++)
- {
- cin>>pos_ini1[j];
- }
- for(int j = 0; j<3;j++)
- {
- cin>>acele1[j];
- }
- for(int j = 0; j<3;j++)
- {
- cin>>pos_ini2[j];
- }
- for(int j = 0; j<3;j++)
- {
- cin>>acele2[j];
- }
- for(int j = 0; j<3;j++)
- {
- dif_pos[j]=pos_ini1[j]-pos_ini2[j];
- dif_ace[j]=(acele1[j]- acele2[j])/2;
- }
- prod_int = dotProduct(dif_pos, dif_ace);
- norm_a = get_norm(dif_ace);
- norm_r = get_norm(dif_pos);
- delta = prod_int*prod_int - norm_a*norm_a*(norm_r*norm_r - (r1+r2)*(r1+r2));
- if(norm_a>0)
- {
- if(delta>=0)
- {
- if((-prod_int+sqrt(delta))>0 || (-prod_int-sqrt(delta))>0)
- resposta[i]=1;
- else
- resposta[i]=0;
- }
- else
- resposta[i]=0;
- }
- else
- resposta[i]=0;
- }
- for (int i = 0; i < t ; i++)
- {
- if(resposta[i]==1)
- cout<<"YES"<<endl;
- else
- cout<<"NO"<<endl;
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement