比赛 noip-081029 评测结果 AAWWWWWWWW
题目名称 最多因子数 最终得分 20
用户昵称 zqzas 运行时间 0.000 s
代码语言 C++ 内存使用 0.00 MiB
提交时间 2008-10-29 22:10:30
显示代码纯文本
#include <iostream>
#include <cmath>

#define MAXP 500

using namespace std;

long long low,up,ans1,ans2,many,prime[MAXP];

void run()
{
	int zan,p,now=1,now2;
	many=0;
	for (int i=1;i<=prime[0];i++)
	{
		if (now*prime[i]>up)
			break;
		now*=prime[i];
		many++;
		now2=now;
		p=0;
		while (now*2<=up)
		{
			now*=2;
			p++;
		}
		zan=1<<many;
		zan+=(1<<(many-1))*p;
		if (zan>ans2 || (zan==ans2 && now<ans1))
		{
			ans2=zan;
			ans1=now;
		}
		now=now2;
	}
}

void ini()
{
	cin>>low>>up;
	//make prime
	int flag;
	for (int i=2;i<=MAXP;i++)
	{
		flag=1;
		for (int j=2;j<=sqrt((double)i);j++)
			if (i%j==0)
				flag=0;
		if (flag)
			prime[++prime[0]]=i;
	}
}

int main()
{
	freopen("divisors.in","r",stdin);
	freopen("divisors.out","w",stdout);
	ini();
	run();
	printf("Between %d and ",low);
	printf("%d,",up);
	printf("%d has a maximum of ",ans1);
	printf("%d divisors.",ans2);
	return 0;
}