below is my code for the problem(Code: RECIPE). I’m getting wrong answer but all the test cases I’m trying are showing correct output. And I also don’t think there is problem of time complexity.
Please help me to find my mistake!!!
using namespace std;
int main()
{
int t,n,m=0,count;
cin>>t;
while(t--){
cin>>n;
int a[n];
for(int i=0; i<n; i++){
cin>>a[i];
}
m=a[0];
count=0;
for(int i=1; i<n; i++){
if(a[i]<=m)
m=a[i];
}
for(int i=0; i<n; i++){
if(a[i]%m==0)
count++;
}
if(count!=n){
for(int i=0; i<n; i++){
cout<<a[i]<<" ";
}
}
if(count==n){
for(int i=0; i<n; i++){
cout<<a[i]/m<<" ";
}
}
cout<<""<<endl;
}
return 0;
}