Advertisement
cupsamada

baze n, t, k

Dec 18th, 2019
113
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.96 KB | None | 0 0
  1. #include<iostream>
  2. using namespace std;
  3. int main()
  4. {
  5. int xb, x10, pb, b, cifmax, aux1, aux2, aux3, cifra, maxim=0, ogl, nb, ok=0;
  6. cin>>xb;
  7. aux1=xb;
  8. while(aux1!=0)
  9. {
  10. cifra=aux1%10;
  11. if(cifra>maxim)
  12. {
  13. cifmax=cifra;
  14. }
  15. aux1=aux1/10;
  16.  
  17. } cout<<cifmax<<" ";
  18. for(b=cifmax+1; b<=10; b++)
  19. {
  20. x10=0;
  21. pb=1;
  22. aux2=xb;
  23. while(aux2)
  24. {
  25. cifra=aux2%10;
  26. x10=x10+cifra*pb;
  27. pb=pb*b;
  28. aux2=aux2/10;
  29. }
  30. if(cifmax==b-1)
  31. {
  32. nb=x10;
  33. }
  34. ogl=0;
  35. aux3=x10;
  36. while(aux3)
  37. {
  38. ogl=ogl*10+aux3%10;
  39. aux3=aux3/10;
  40. }
  41. if(x10==ogl)
  42. {
  43. ok=1;
  44. break;
  45. }
  46. }
  47. if(ok==1)
  48. {
  49. cout<<b;
  50. }
  51. else
  52. {
  53. cout<<nb;
  54. }
  55. return 0;
  56. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement