ICPC Central Russia Regional Contest (CRRC 18) D
Posted yeah17981
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了ICPC Central Russia Regional Contest (CRRC 18) D相关的知识,希望对你有一定的参考价值。
题目大意:给定k,求因子个数为k的最小数
咕了一个礼拜了都有,反正我现在认识到py还是要学的
先上zpc的代码,感谢zpc,因为高精度的问题所以用的py
primes = [0, 2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47]
#质数表
inf = 10 ** 100000
#长知识了,**是乘方
n = int(input())
if n == 1 :
print(1)
exit(0)
ans = inf
power = [0]
for i in range(1, 1001) :
if n % i == 0 :
power.append(i)
#append()函数,用于在列表尾添加元素,因子
dp = [[inf for i in range(0, len(power) + 10)] for j in range(0, len(primes) + 10) ]
#一个二维数组,行数是 len(primes)+10,列数是 len(power)+10,所有元素都是 inf,感谢御坂14491的指导
dp[0][1] = 1
for i in range(0, len(primes) - 1) :
#质数表
for j in range(1, len(power)) :
#因子表
if dp[i][j] == inf :
continue
for k in range(j + 1, len(power)) :
if power[k] % power[j] == 0 :
dp[i + 1][k] = min(dp[i + 1][k], dp[i][j] * (primes[i + 1] ** (power[k] // power[j] - 1)))
if k == len(power) - 1 :
ans = min(ans, dp[i + 1][k])
print(ans)
然后上妖鱼给的题解,感谢妖鱼,虽然我不知道他俩做法是不是一样(逃)
以上是关于ICPC Central Russia Regional Contest (CRRC 18) D的主要内容,如果未能解决你的问题,请参考以下文章
2019-2020 ICPC North-Western Russia Regional Contest
ICPC 2019-2020 North-Western Russia Regional Contest E. Equidistant(分层)
ICPC 2019-2020 North-Western Russia Regional Contest E. Equidistant(分层)
05.24 ICPC 2019-2020 North-Western Russia Regional Contest复现赛+Codeforces Round #645 (Div. 2)
05.24 ICPC 2019-2020 North-Western Russia Regional Contest复现赛+Codeforces Round #645 (Div. 2)