Codeforces 1355A. Sequence with Digits Solution

 ///La ilaha illellahu muhammadur rasulullah

///******Bismillahir-Rahmanir-Rahim******///

///Abul Hasnat  Tonmoy

///Department of CSE,23rd batch

    ///Islamic University,Bangladesh

    1. #include <bits/stdc++.h>
    2. using namespace std;
    3. int main()
    4. {
    5. long long t;
    6. cin>>t;
    7. while(t--)
    8. {
    9. long long a,k,x,y,n;
    10. cin>>a>>k;
    11. for(int i=2; i<=k; i++)
    12. {
    13. x=9,y=0,n=a;
    14. while(n)
    15. {
    16. x=min(x,n%10);
    17. y=max(y,n%10);
    18. n=n/10;
    19. }
    20. if(x==0)
    21. break;
    22. a+=(x*y);
    23. }
    24. cout<<a<<endl;
    25. }
    26. }

    No comments

    Most View Post

    Recent post

    RESTful APIs with CRUD Operations in Laravel 12| (2025)

      RESTful APIs serve as the foundation of modern web development. They follow a set of rules called Representational State Transfer (REST) t...

    Powered by Blogger.