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

    Codeforces Round 971 (Div. 4) 2009C. The Legend of Freya the Frog Solution

      Problem Link    https://codeforces.com/contest/2009/problem/C S olution in C++: /// Author : AH_Tonmoy #include < bits / stdc ++. h ...

    Powered by Blogger.