Advertisement
cupsamada

cv 2014

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