编程介的小学生 2019-01-07 00:39 采纳率: 20.5%
浏览 588
已采纳

数字求和的分解问题,计算一个数字是否可以分解a+b=p,采用C语言

Problem Description
Let d(x) be the sum of all divisors of x. x is called a good number if every number from 1 to d(x) can be expressed as a sum of distinct divisors of x.

For example, 6 is a good number, d(6)=1+2+3+6=12, 4=1+3,5=2+3,7=1+6 and so on.

Teacher Mai wants to know whether a even number p can be expressed as a sum of two good numbers.

Input
There are multiple test cases(about 40000).

For each test case, there is only one line contains one even number p(1≤p≤1018).

Most test cases are generated randomly.

Output
For each test case, print "YES" or "NO" in the first line. That means if is possible to express p as a sum of two good numbers.

If your answer is "YES", print two number a,b in the second lines. Both a and b should be good numbers, and a+b=p.

In the third and the fourth line, print the factorization of number a and b. If a=∏ki=1peii, where p1<p2<⋯<pk, pi are all prime numbers and ei≥1, you should print k first, then 2k space-seperated numbers p1,e1,p2,e2,⋯,pk,ek.

Sample Input
18

Sample Output
YES
6 12
2 2 1 3 1
2 2 2 3 1

  • 写回答

2条回答 默认 最新

  • threenewbee 2019-12-17 23:25
    关注
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 NAO机器人的录音程序保存问题
  • ¥15 C#读写EXCEL文件,不同编译
  • ¥15 MapReduce结果输出到HBase,一直连接不上MySQL
  • ¥15 扩散模型sd.webui使用时报错“Nonetype”
  • ¥15 stm32流水灯+呼吸灯+外部中断按键
  • ¥15 将二维数组,按照假设的规定,如0/1/0 == "4",把对应列位置写成一个字符并打印输出该字符
  • ¥15 NX MCD仿真与博途通讯不了啥情况
  • ¥15 win11家庭中文版安装docker遇到Hyper-V启用失败解决办法整理
  • ¥15 gradio的web端页面格式不对的问题
  • ¥15 求大家看看Nonce如何配置