Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <sstream>
- using namespace std;
- string x;
- int main()
- {
- unsigned long long a, b;
- cin>>b;
- cin>>a;
- while (a!=0)
- {
- if (a%2==1)
- x=x+'1';
- else x=x+'0';
- a/=2;
- }
- unsigned long long wynik=1;
- unsigned long long ptg=1;
- for (unsigned long long i=0; i<x.length(); i++)
- {
- unsigned long long pom=1;
- if (x[i]=='1')
- {
- for (unsigned long long j=1; j<=ptg; j++)
- pom*=b;
- wynik*=pom;
- }
- ptg*=2;
- }
- cout<<wynik;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement