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
- #include <bits/stdc++.h>
- using namespace std;
- int main()
- {
- long long t;
- cin>>t;
- while(t--)
- {
- long long a,k,x,y,n;
- cin>>a>>k;
- for(int i=2; i<=k; i++)
- {
- x=9,y=0,n=a;
- while(n)
- {
- x=min(x,n%10);
- y=max(y,n%10);
- n=n/10;
- }
- if(x==0)
- break;
- a+=(x*y);
- }
- cout<<a<<endl;
- }
- }
No comments