#include <iostream> int main() { int num; while(std::cin>>num) { int mod, left, sum=0; left = mod % 3; while(num/3) { mod = num / 3; left = num % 3; sum += mod; num = mod + left; left = num % 3; } if(left == 1) { sum += 0; } if(left == 2) { sum += 1; } std::cout<<sum<<std::endl; } return 0; }
来源:https://www.cnblogs.com/donggongdechen/p/11915075.html