the question is to find no of reversible no.s below the following test cases and here reversible no.s means like 36 + 63 = 99
(contains both odd digit). both 36
and 63
are reversible . and we have to find total reversible no.s below a number.
i have also declared functions as inline
, but it is still giving timeout error . for test case#1 to test case#5
inline std::string IntToString ( int number )
{
std::ostringstream oss;
oss<< number;
return oss.str();
}
inline int replacer (int n)
{
int r,R=0;
while(n!=0)
{
r=n%10 ;
R=R*10+r ;
n=n/10;
}
return R ;
}
int main() {
/* Enter your code here. Read input from STDIN. Print output to STDOUT */
int i,n,t,j,R,Q,L,k,d=0,M=0,D;
cin>>t ;
for(i=0;i<t;i++ )
{
M=0;
cin>>n ;
for(j=1;j<n;j++)
{
if(j%10!=0)
{ d=0;
R= replacer(j) ;
Q=R+j ;
std::string C = IntToString (Q);
L=C.size() ;
for(k=0;k<L;k++)
if(C[k]%2==0)
d=1 ;
if(d==0)
M++ ;
}
}
cout<<M<<endl ;
}
return 0;
}
Aucun commentaire:
Enregistrer un commentaire