比赛 NOIP2023模拟赛5 评测结果 AAAAAAATTATTTTTTTTTTTT
题目名称 Number With The Given Amount Of Divisors 最终得分 36
用户昵称 Benjamin 运行时间 14.089 s
代码语言 C++ 内存使用 3.91 MiB
提交时间 2023-11-17 11:00:01
显示代码纯文本
#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long ull;

ull n,d,s,num,ans;

int main()
{
	freopen("CF27E.in","r",stdin);
	freopen("CF27E.out","w",stdout);
	cin>>n;
	ull zhaodao=0;
	num=n;
	while(!zhaodao)
	{
		s=0;
		for(ull i=1;i<=sqrt(num*1.0);i++)
		{//枚举求约数个数
			if(num%i==0)s++;
		}
		s *= 2;//约数个数翻倍
		//如果平方根为整数,则平方根多算1次,减去1
		if(sqrt(num*1.0)-(ull)sqrt(num*1.0)==0) s-=1;
		if(s==n)//满足条件
			ans=num,zhaodao=1;
		else
			num++;//否则,尝试下一个数
	}
	cout<<ans<<endl;
	return 0;
}