Im not able to pass testcases 5 please help me to solve this

Revision en1, by hackersarkar12, 2019-10-01 09:01:07

The question is

https://mirror.codeforces.com/contest/489/problem/C

include

#include<bits/stdc++.h>
#include<math.h>

using namespace std;
int main(){long long int j,no,i,sum1,sum,d=0,d2=0,rem=0,i1,large,large1=0;
    cin>>j>>no;
    if(j>6){
        cout<<0<<" "<<0;
    }

    if(j<6){ 


    if(no==0){
        cout<<-1<<" "<<-1;
    }


    else{
    for(i=(pow(10,j)-1);i>=pow(10,(j-1));i--){

        sum1=0;
        sum=0;
        i1=i;
        while(i1!=0){
            rem=i1%10;
            sum1=sum1+rem;
            sum=(sum*10)+rem;    
            i1=i1/10;    
        }

        if(sum1==no){

            d2=i;
            large=i;
            if(large1<=large){
            large1=large;
        }


        }
    }
    if(no>1){
    cout<<d2<<" "<<large1;
    }
    if(no==1){
        cout<<i+1<<" "<<i+1;
    }
}
}
  return 0;  
}

History

 
 
 
 
Revisions
 
 
  Rev. Lang. By When Δ Comment
en1 English hackersarkar12 2019-10-01 09:01:07 1261 Initial revision (published)