Saleh127

Untitled

May 16th, 2020
131
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.70 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3. #define test int t; cin>>t; while (t--)
  4. #define ll long long int
  5. #define sc(a) scanf("%lld",&a)
  6. #define sc2(a,b) scanf("%lld %lld",&a,&b)
  7. #define pf(a) printf("%lld",a)
  8. #define loop1(i,a,c) for(i=a;i<=c;i++)
  9. #define loop(i,c) for(i=0;i<c;i++)
  10. int main()
  11. {
  12. ll a,n,c,d,e,f,i,j,l,k;
  13. test
  14. {
  15. cin>>n>>k;
  16. for(i=0;i<k-1;i++)
  17. {
  18. d=0;
  19. e=9;
  20. a=n;
  21. while(a>0)
  22. {
  23. c=a%10;
  24. if(c>d) d=c;
  25. if(c<e) e=c;
  26. a=a/10;
  27. }
  28. n=n+(d*e);
  29. }
  30. cout<<n<<endl;
  31. }
  32. return 0;
  33. }
Advertisement
Add Comment
Please, Sign In to add comment