cutting recipes

test cases are working properly but still wrong answer
#include

using namespace std;
int main()
{
int n,t,i,j,count=0,min;
int a[50];
cin>>t;
while(t>0)
{
cin>>n;
for(i=0;i<n;i++)
cin>>a[i];
min=a[0];
for(i=0;i<n;i++)
{
if(a[i]<min)
min=a[i];
}
count=0;
for(i=0;i<n;i++)
{
if(a[i]%min==0)
count++;
}
if(count==n)
{

                      for(i=0;i<n;i++)
                      cout<<a[i]/min<<" ";
                      }
                      else
                      for(i=0;i<n;i++)
                      cout<<a[i]<<" ";
                      cout<<endl;

t–;
}

return 0;
}

All test cases are not working.

Try the case,

1

3 4 6 8

The answer according to your solution is 4 6 8, which is wrong.

The correct output for this test case is 2 3 4

The reason your logic is giving correct answer for all sample test cases is that the gcd of all sample cases is either the minimum number or 1.

Try a different logic.


If you have any problem comment below.
//