题解 CF1811E 【Living Sequence】
我们把原题中“不能有
发现这正好是十进制转九进制后的数列。这样就可以把原题转换成一道简单的进制转换题了。
因为原题是“不能有
根据数据范围,所以需要开
代码如下:
#include <iostream>
#include <cstdio>
#include <cmath>
using namespace std;
#define N 21
int a[N];
long long n;
int j;
int main()
{
int t;
cin>>t;
for(int R=1;R<=t;R++)
{
cin>>n;
for(j=0;;j++)
{
a[j]=n%9;
if(a[j]>=4) a[j]++;
n/=9;
if(n==0) break;
}
for(;j>=0;j--)
printf("%d",a[j]);
cout<<endl;
}
return 0;
}