目前最优解代码
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
void solve(){
string s;
cin>>s;
int p=1,ans=0;
//p:9^j
for (int i=s.size()-1;i>=0;i--){
int x=s[i]-'0';
if (x>7) x--;
//ans+=9^j*x
ans+=p*x;
p*=9;
}
cout<<ans<<'\n';
}
int main(void){ std::ios::sync_with_stdio(false);
cin.tie(0),cout.tie(0);
int t = 1;
cin>>t;
while (t--){
solve();
}
return 0;
}
输入输出
2
69
70
62
63
显然有问题,不知道之前所谓的加强数据是否有考虑过这种情况?