因为满足的数很少,我们预处理所有的因子和,把满足的数找出来两两一对,最后直接判断是否在区间内,将答案除以2即可。
#include<stdio.h>
#include <iostream>
#include <algorithm>
using namespace std;
#include <cstring>
typedef long long ll;
#include <map>
#include <set>
//int a[11000010];
//int b[11000010];
int c[300]= {284,220,220,284,1210,1184,1184,1210,2924,2620,2620,2924,5564,5020,5020,5564,6368,6232,6232,6368,10856,10744,10744,10856,14595,12285,12285,14595,18416,17296,17296,18416,76084,63020,66992,66928,66928,66992,71145,67095,87633,69615,67095,71145,63020,76084,88730,79750,69615,87633,79750,88730,124155,100485,139815,122265,123152,122368,122368,123152,100485,124155,122265,139815,153176,141664,168730,142310,141664,153176,142310,168730,176336,171856,180848,176272,171856,176336,176272,180848,203432,185368,202444,196724,196724,202444,185368,203432,365084,280540,389924,308620,430402,319550,399592,356408,280540,365084,308620,389924,356408,399592,319550,430402,455344,437456,437456,455344,486178,469028,469028,486178,514736,503056,503056,514736,525915,522405,522405,525915,669688,600392,686072,609928,691256,624184,712216,635624,652664,643336,643336,652664,783556,667964,600392,669688,609928,686072,624184,691256,635624,712216,796696,726104,667964,783556,726104,796696,863835,802725,802725,863835,901424,879712,980984,898216,879712,901424,1125765,947835,898216,980984,1043096,998104,998104,1043096,1099390,1077890,1077890,1099390,947835,1125765,1189150,1154450,1292570,1156870,1438983,1175265,1286744,1185376,1154450,1189150,1340235,1280565,1185376,1286744,1156870,1292570,1483850,1328470,1280565,1340235,1486845,1358595,1464592,1392368,1175265,1438983,1392368,1464592,1747930,1466150,1749212,1468324,1328470,1483850,1358595,1486845,1598470,1511930,1511930,1598470,2062570,1669910,1466150,1747930,1468324,1749212,1870245,1798875,1798875,1870245,1669910,2062570,2090656,2082464,2082464,2090656,2429030,2236570,2236570,2429030,2941672,2652728,2874064,2723792,3077354,2728726,2928136,2739704,2947216,2802416,3716164,2803580,2723792,2874064,2739704,2928136,2652728,2941672,2802416,2947216,2728726,3077354,3721544,3276856,3892670,3606850,2803580,3716164,3276856,3721544,4300136,3786904,4006736,3805264,3606850,3892670,3805264,4006736,4314616,4238984,4488910,4246130,4445050,4259750,3786904,4300136,4238984,4314616,4259750,4445050,4246130,4488910};
//int len;
//void geteuler()
//{
// int i,j;
// len=0;
// memset(a,0,sizeof(a));
// memset(b,0,sizeof(b));
// int ans=0;
// for(i=2; i<5000005; i++)
// for(j=i+i; j<5000005; j+=i)
// a[j]+=i;
// for(i=1; i<5000005; i++)
// a[i]+=1;
// a[1]=0;
// for(i=1; i<=5000000; i++)
// {
// int t=a[i];
// if(i==a[t]&&i!=t)
// {
// ans++;
// // cout<<t<<" "<<a[t]<<endl;
// c[len++]=t;
// c[len++]=a[t];
// }
// }
// cout<<ans<<endl;
//}
int main()
{
// geteuler();
// cout<<len<<endl;
// for(int i=0;i<len;i++)
// cout<<c[i]<<",";
// int c,d;
int a,b;
while(cin>>a>>b)
{
int ans=0;
for(int i=0; i<284; i+=2)
if(c[i]>=a &&c[i]<=b &&c[i+1]>=a &&c[i+1]<=b)
ans++;
cout<<ans/2<<endl;
}
return 0;
}