I AM GETTING EXPECTED OUTPUT ,THEN ALSO VERDICT IS "WRONG ANSWER" PLEASE RUN!

I have participated in SNACKDOWN 21 and the question in the contest is “CodeChef: Practical coding for everyone
The contest is ended,so I am asking a question please help.

#include
using namespace std;
int main ()
{

int t;// ,n,i,a,c,pre=0,pre_a=0;

cin>>t;
while(t>0)
{
int n,i,a,c,pre=0;
signed pre_a=-1;
–t;
cin>>n;

int b[n];

for(i=0;i<n;++i)
{
cin>>b[i];
}

for(i=0;i<n;++i)
{
for(a=0;a<n;++a)
{
c=a%b[i];

  if(b[i]==1)
  {
   // pre=c;
    if(a>pre_a)
      {   
          pre_a=a;
          cout<<pre_a<<"\t";
          break;
      }
      
      else if(c<pre)
      {
        cout<<a<<"\t";
          break;
      }
      
      
    else;
  }

  else if((b[i]>1)&&(a>0))
  {
      pre=c;
      
      if(a>pre_a)
      {
        pre_a=a;
        cout<<pre_a<<"\t";
        break;
      }
      else;
  }
  else;
}

}

cout<<endl;

}
return 0;
}

Please either format your code or (better!) link to your submission - the forum software has mangled it and it won’t compile! :slight_smile:

1 Like

this is the link of my solution

https://www.codechef.com/viewsolution/52680330

1 Like