素数之积

标题:素数之积 | 时间限制:1秒 | 内存限制:262144K | 语言限制:不限
RSA加密算法在网络安全世界中无处不在,它利用了极大整数因数分解的困难度,数据越大,安全系数越高,给定一个32位正整数,请对其进行因数分解,找出是哪两个素数的乘积。

def factor(num):
    if num == 1:
        return []
    else:
        for i in range(2, num+1):
            a, b = divmod(num, i)
            if b == 0:
                return [i] + factor(a)
while True:
    try:
        num = int(input())
        if num > 2147483646:
            print('-1 -1')
        list_out = factor(num)
        if len(list_out) == 2:
            print('{} {}'.format(list_out[0], list_out[1]))
        else:
            print('-1 -1')
    except:
        break


全部评论

相关推荐

想申请延毕了,找工作找到崩溃,越找就越想摆烂,还有25届的和我一样感受吗?
码农索隆:没事哒,好兄弟,慢慢来,调整心态,车到山前必有路,感到迷茫的时候,多抬头看看
点赞 评论 收藏
分享
点赞 评论 收藏
分享
04-21 11:22
已编辑
中华女子学院 UE4
耐心学习_佩可officical:直接举报他,佬,违反劳动法我记得boss会下架
点赞 评论 收藏
分享
评论
1
1
分享

创作者周榜

更多
牛客网
牛客企业服务