提交时间:2020-08-14 17:39:45

运行 ID: 5712

#include<bits/stdc++.h> using namespace std; int main(){ int n,m,e; cin>>n; for(int i=1;i<=n;i++){ cin>>m; int sum=0; if(m+1<3){ cout<<sum; continue; } e=m; while((m+e%3)/3+1>=3){ sum+=(m+e%3)/3; m/=3; if(m/3+e%3==2){ sum++; continue; } e=m; } cout<<sum<<endl; } return 0; }