3259. Mysterious Number

Mysterious Number refers to a number which can be divisible by the number of distinct factors that it has. For instance, 1 (1 factor), 12 (6 factors) and 9 (3 factors) are Mysterious Numbers, but 7(2 factors) or 16 (5 factors) are not.

Given two integers low and high, please calculate the number of Mysterious Numbers between low and high, inclusive.

Input

For each test case, there are two integers low and high in one line separated by spaces. 1 ≤ lowhigh ≤ 1,000,000

Output

Print out the number of Mysterious Numbers between low and high, inclusive.

Sample Input

1 10
10 15

Sample Output

4

1

#include<stdio.h>
#include<cstring>
const int num=1000001;
int a[num],b[num];
void f(){
	memset(a,0,sizeof(a));
	a[1]=1;
	for(int i=2;i<num;i++)
	{
		if(!a[i])
		{
			a[i]=2;
			for(int j=i+i;j<num;j=j+i)
			{
				a[j]=a[j]+1;
			}
		}
		else
		{
			a[i]=a[i]+2;
			for(int j=i+i;j<num;j=j+i)
				a[j]=a[j]+1;
		}
	}
	b[0]=0;
	for(int i=1;i<num;i++)
	{
		if(i%a[i]==0)
			b[i]=1;
		b[i]=b[i]+b[i-1];
	}
}
int main(){
	int low,high,r;
	f();
	while(scanf("%d%d",&low,&high)!=EOF){
		
		printf("%d\n",b[high]-b[low-1]);
	}	
	return 0;
}


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值