The following is my code for this"-https://www.codechef.com/problems/MUFFINS3 " question.
#include<iostream>
using namespace std;
int main()
{
int T;
cin>>T;
int arr[T];
for(int i=0;i<T;i++)
cin>>arr[i];
for(int i=0;i<T;i++)
{
int temp=0;
int largest=0;
for(int j=1;j<=arr[i];j++)
{
static int largest=0;
if(arr[i]%j>=largest)
{
largest=arr[i]%j;
temp=j;
}
}
cout<<temp<<endl;
}
}
I’m not getting a proper answer for dissimilar items. Can someone please point out the error in my code?