I changed cin/cout to scanf/printf but still it gives me time limit exceeded error.Can someone please tell me how to rectify it?
#include <stdio.h>
#include <iostream>
using namespace std;
int main()
{
int t,a,max,rem,i;
scanf("%d",&t);
rem=0;
while(t>0)
{
scanf("%d",&a);
for(i=2;i<=a;i++)
{
if(a%i>=rem)
{
rem=a%i;
max=i;
}
}
printf("%d\n",max);
t--;
}
return 0;
}