 # https://www.codechef.com/problems/RECIPE

https://www.codechef.com/problems/RECIPE

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.

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;
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;
``````

}

1 Like

Try this test case:

Input

``````1
2 24 36
``````

Expected Output

``````2 3
``````

``````24 36
``````

thank you very much i got my mistake
thanks for the help

1 Like

thanks man… i got my mistake
thank you for helping

**try this case **
1
5 1000 55 590 400 750

the fault in your approach is that you’re finding the minimum number in the array and then checking if all the other numbers in the array are its multiples or not ,where as you should try find a highest common factor for all elements of array which lies between 2 and the smallest number in the array