MAX69NOMLSC - Editorial

PROBLEM LINK:

Practice

Author: Kunal Demla
Editorialist: Kunal Demla

DIFFICULTY:

cakewalk

PREREQUISITES:

Maths?

SOLUTIONS:

Setters' Solution
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
int maximum69Number (int num) {
        int i=0,c=0;
        int n=num;
        while(n){
            i++;
            if(n%10==6)
                c=i;
            n/=10;
        }
        if(c==0)
            return num;
        return num+3*pow(10,c-1);
    }

void solve()
{
    ll n,m,x,y,i,j,k,q;
    cin>>n;
    cout<<maximum69Number(n);
}

int main()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);

#ifndef ONLINE_JUDGE
freopen("input.txt", "r", stdin);
freopen("error.txt", "w", stderr);
freopen("output.txt", "w", stdout);
#endif

int t=1;
// cout<<t<<endl;
// ${2:is Single Test case?}cin>>t;
cin>>t;
int n=t;
while(t--)
{
    //cout<<"Case #"<<n-t<<": ";
    solve();
    cout<<"\n";
}

cerr<<"time taken : "<<(float)clock()/CLOCKS_PER_SEC<<" secs"<<endl;
return 0;
}