My issue
while running it is giving the correct output with time of 0.09sec but while submitting it is showing tle
My code
/* package codechef; // don't place package name! */
import java.util.*;
import java.lang.*;
import java.io.*;
/* Name of the class has to be "Main" only if the class is public. */
class Codechef
{
public static void main (String[] args) throws java.lang.Exception
{
Scanner sc = new Scanner(System.in);
int temp,r=0,c=0,digi=0,even=0,odd=0,i,n=1;
int t = sc.nextInt();
while(t>0)
{
t--;
int num = sc.nextInt();
for(i=1;i<=num;)
{
for(int j=1;j<=n;j++)
{
if(n%j==0)
c++;
}
temp=n;
while(temp>0)
{
r=r*10+temp%10;
temp=temp/10;
}
if(r==n&&c==2)
{
//System.out.print(n+",");
i++;
temp=n;
while(temp>0)
{
temp=temp/10;
digi++;
}
if(digi%2==0)
even++;
else
odd++;
}
digi=0;
c=0;
r=0;
n++;
}
System.out.println(even+" "+odd);
even=0;
odd=0;
n=1;
}
}
}
Problem Link: Palindromic Prime Numbers Practice Coding Problem - CodeChef