The question is
https://codeforces.net/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; }
Why you are printing 0 0 when j>6 ? Your whole approach is wrong. Either find another approach or you can visit my solution https://codeforces.net/contest/489/submission/61648279
Hope it helps :)