关于这个题这样做的可行性
  • 板块P1748 H数
  • 楼主mot1ve
  • 当前回复1
  • 已保存回复1
  • 发布时间2022/11/19 20:35
  • 上次更新2023/10/27 02:18:57
查看原帖
关于这个题这样做的可行性
250699
mot1ve楼主2022/11/19 20:35

为什么要用set去重呢,质因子的乘积应该都是唯一的吧,唯一分解定理证明就可以啊,只不过是逆定理。

#include<bits/stdc++.h>
using namespace std;
int n,idx=0;
double b[5000010];
signed main()
{
	cin>>n;
	if(n==0)
	{
		cout<<0;
		return 0;
	}
	for(int x1=0;x1<=70;x1++)
	{
		for(int x2=0;x2<=50;x2++)
		{
			for(int x3=0;x3<=30;x3++)
			{
				for(int x4=0;x4<=30;x4++)
				{
					double ans=pow(2,x1)*pow(3,x2)*pow(5,x3)*pow(7,x4);
					if(ans>1e19)
					break;
					b[++idx]=ans;
				}
			}
		}
	}
	sort(b+1,b+1+idx);
	cout<<(long long)b[n];
	return 0;
}
2022/11/19 20:35
加载中...