why using for loop will not give TLE insted using while.(to iterate testcase)
ex->> Solution: 42640665 | CodeChef (TLE with while)
(acc. but wa)
#include <bits/stdc++.h>
#include
#include
#define ll long long int
using namespace std;

int main ()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
ll t=0;
cin>>t;
for(int i=0; i<t; i++)
//while(t–)
{ // cout<<“Chef”<<endl;

ll x=0,y=0;
cin>>x>>y;
if(x==1 || x==2 )
cout<<“Chef\n”;

else if(x=3 && y==1)
cout<<“Divyam’\n”;
else if(x==4 && y>=2)
cout<<“Chef’\n’”;

else if(x==4 && y>=2)
cout<<“Chef’\n’”;
else if(x==4 && y==1)
cout<<“Divyam’\n’”;

else if(x==5 || x==6 && y>=3)
cout<<“Chef’\n’”;
else if(x==5 || x==6 && y<3)
cout<<“Divyam’\n’”;

}

}

Its not the case of for and while here, you commented out
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
Thats what causing your tle, however your approach is incorrect in both of the solutions.
If the number of prime numbers allowed is more than or equal to the prime number which are less then than N, then chef will win, else Divyam will win.

1 Like

@sachin0102 sorry dude i messed up
same this but (wa)

``````#include <algorithm>
#include <vector>
#define ll long long int
using namespace std;

int main ()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
ll t=0;
cin>>t;
for(int i=0; i<t; i++)
//while(t--)
{ // cout<<"Chef"<<endl;

ll x=0,y=0;
cin>>x>>y;
if(x==1  || x==2 )
cout<<"Chef\n";

else if(x=3 && y==1)
cout<<"Divyam'\n";
else if(x==4 && y>=2)
cout<<"Chef'\n'";

else if(x==4 && y>=2)
cout<<"Chef'\n'";
else if(x==4 && y==1)
cout<<"Divyam'\n'";

else if(x==5 || x==6 && y>=3)
cout<<"Chef'\n'";
else if(x==5 || x==6 && y<3)
cout<<"Divyam'\n'";

}

}
check this code and i know it's WA i am just asking about loop thing
and i can not upload link becuz. i am not getting it from my submission.