提交时间:2020-08-14 17:35:21

运行 ID: 5708

#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/3+e%3+1>=3){ sum+=m/3+e%3; m/=3; if(m/3+e%3==2){ sum++; continue; } e=m; } cout<<sum<<endl; } return 0; }