题目:
添加链接描述
分析:
代码(算法1):
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<cstdlib>
#include<algorithm>
#include<set>
#include<queue>
#include<vector>
#include<map>
#include<list>
#include<ctime>
#include<iomanip>
#include<string>
#include<bitset>
#include<deque>
#include<set>
#define LL long long
#define ch cheap
using namespace std;
inline LL read() {
LL d=0,f=1;char s=getchar();
while(s<'0'||s>'9'){if(s=='-')f=-1;s=getchar();}
while(s>='0'&&s<='9'){d=d*10+s-'0';s=getchar();}
return d*f;
}
LL w[22685];
LL s(LL x)
{
LL sum=0;
while(x) sum+=(x%10),x/=10;
return sum;
}
LL D(LL x)
{
return x<10?x:D(s(x));
}
int main()
{
for(LL i=1;i<=22680;i++)
{
w[i]=w[i-1];
for(LL j=1;j<10;j++)
if(!(i%j)&&D(i/j)==j) {w[i]++;break;}
}
LL t=read();
while(t--)
{
LL l=read(),r=read();
l--;
LL a,b;
a=(r/22680)*w[22680]+w[(r%22680)];
b=(l/22680)*w[22680]+w[(l%22680)];
printf("%lld\n",a-b);
}
return 0;
}