#include <bits/stdc++.h>
#define fast ios_base::sync_with_stdio(false),cout.tie(NULL),cin.tie(NULL)
#define endl "\n"
#define ll long long
#define all(a) (a).begin(),(a).end()
#define repp(i,a,b) for(int i = a;i<b;i++)
#define repn(i,a,b) for(int i = a;i<b;i++)
using namespace std;
int gcd(int a, int b)
{
if (a == 0)
return b;
return gcd(b % a, a);
}
int findNumber(int arr[], int n)
{
// Find GCD of array
int ans = arr[0];
for (int i = 0; i < n; i++)
ans = gcd(ans, arr[i]);
return ans;
}
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
int Times;
cin>>Times;
while(Times--)
{
int n;
cin>>n;
int arr[n];
repp(i,0,n)
{
cin>>arr[i];
}
int ab = findNumber(arr,n);
if (ab>1)
repp(i,0,n){
arr[i] = arr[i]/ab;
}
repp(i,0,n)
{
cout<<arr[i]<<" ";
}
cout<<endl;
}
return 0;
}
Please either format your code or link to your submission - the forum software has mangled it and it won’t compile!
Also, please tell us which Problem it is you’re trying to solve - I’m guessing it’s RECIPE?
2 Likes
yes the problem is RECIPE