#include<bits/stdc++.h>
using namespace std;
long long d, ans=0, f[520000];
long long t;
inline bool init(int a)
{
int k,m,b=a%10;
a/=10;
int c=a%10;
a/=10;
k=b-c;
while(a!=0) {
int r=a%10;
if(c-r==k) {
c=r;
a/=10;
continue;
} else return false;
}
return true;
}
int main()
{
for(int i=1;i<=11;i++) {
for(int j=0;j<=60;j++){
int tmp=i*100+j;
if(init(tmp)) f[i*60+j]=f[i*60+j-1]+1;
else f[i*60+j]=f[i*60+j-1];
}
}
cin>>d;
while(d--)
{
cin>>t;
if(t>720) {
long long mod=t/720;
long long rest=t-mod*720;
cout<<f[720]*mod+f[rest]+mod+1<<endl;
}
else if(t<34) cout<<0<<endl;
else cout<<f[t]+1<<endl;
}
return 0;
}
求帮助