Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<iostream>
- #include<fstream>
- using namespace std;
- ifstream fin("baze.in");
- ofstream fout("baze.out");
- int main()
- {
- int n, k, t, maxim=0, b, pb, ok=0, x10, cifra;
- fin>>n;
- int aux=n;
- while(aux)
- {
- if(aux%10>maxim)
- {
- maxim=aux%10;
- }
- aux=aux/10;
- }
- for(b=maxim+1; b<=10; b++)
- {
- x10=0;
- aux=n;
- int og=0;
- pb=1;
- while(aux)
- {
- int cifra=aux%10;
- x10=x10+cifra*pb;
- pb=pb*b;
- aux=aux/10;
- }
- aux=x10;
- while(aux)
- {
- og=og*10+aux%10;
- aux=aux/10;
- }
- if(og==x10)
- {
- ok=1;
- break;
- }
- }
- x10=0;
- pb=1;
- if(ok==1)
- {
- fout<<b;
- }
- else
- {
- while(n)
- {
- cifra=n%10;
- x10=x10+cifra*pb;
- pb*=maxim+1;
- n=n/10;
- }
- fout<<x10;
- }
- fin.close();
- fout.close();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement