Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<bits/stdc++.h>
- using namespace std;
- typedef long long ll;
- int main()
- {
- ll n,k;
- cin>>n>>k;
- ll x=n;
- ll a[101]={0};
- ll index=0;
- /// this section is the main algo
- while(n)
- {
- ll reminder=n%k;
- n=n/k;
- a[index]+=reminder;
- index++;
- }
- /// this section is used to print values
- for(int i=0;i<101;i++)
- {
- if(a[i]!=0)
- {
- for(int j=0;j<a[i];j++)
- cout<<k<<"^"<<i<<" + ";
- }
- }
- cout<<"0 = "<<x;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement