Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<iostream>
- #include<vector>
- #include<algorithm>
- using namespace std;
- using ll=long long;
- template<typename T> using V=vector<T>;
- constexpr ll base=6ll*6*6*6*6*6*6*6*6*6*6*6;
- constexpr ll N=1000000000;
- static inline void solve(){
- string str;cin>>str;
- if(str=="0"){
- cout<<1<<endl;
- return;
- }
- V<ll> num;
- while(str.size()>=9){
- num.emplace_back(atoll(str.substr(str.size()-9).data()));
- str.resize(str.size()-9);
- }
- if(str.size())
- num.emplace_back(atoll(str.data()));
- reverse(num.begin(),num.end());
- V<ll> res{0};
- for(auto& x:num){
- ll cur=x;
- for(auto& i:res)
- cur+=i*N,i=cur%base,cur/=base;
- if(cur)
- res.emplace_back(cur);
- }
- int ans=12*(res.size()-1);
- while(res.back()>0)
- ans++,res.back()/=6;
- cout<<ans<<endl;
- }
- signed main(){
- int T=1;
- //cin>>T;
- while(T--)
- solve();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement