QOJ.ac

QOJ

Time Limit: 1 s Memory Limit: 256 MB Total points: 100

#4920. 挑战分解质因数

统计

一天,小 $\Delta$ 给你了一个张纸,上面写了一个很大的数字 $n$ ,他想让你在一秒钟内对它分解质因数,你定睛一看,发现这个数的二进制有高达 $1500$ 位,然后你上网搜索了一下,发现连 RSA-1024 都还没有被分解出来,怎么可能一秒分出来呢?

但是突然你发现他在纸的背面也写了一些东西,你又定睛一看发现写的是 $\varphi(n)$,也就是 $\leq n$ 的且与 $n$ 互质的正整数个数。

这下你好像明白咋分解了,现在你打开了你的电脑,复制出了你的祖传高精度整数运算库,你能一秒钟把结果告诉小 $\Delta$ 吗?

输入格式

一行,两个二进制整数 $n,\varphi(n)$。

输出格式

如果 $n$ 可以表示为 $n=\prod_{i=1}^T p_i$,其中 $p_i$ 是质数,且 $\forall 1\leq i < T, p_i\leq p_{i+1}$,那么首先输出一行,包含一个十进制非负整数 $T$,接下来 $T$ 行,每行一个二进制整数,代表 $p_i$,可以证明这样的表示是唯一的。

样例数据

样例 1 输入

11111101 11011100

样例 1 输出

2
1011
10111

样例 2

见下发文件。

子任务

对于所有数据, $1\leq n< 2^{1500}$。

本题采用捆绑测试,子任务如下:

  1. $n< 2^{32}$ (5分)
  2. $n< 2^{64}$ (15分)
  3. $n< 2^{300}$,$n=pq$,其中 $p,q$ 为不同的质数 (10分)
  4. $n< 2^{300}$,$n=\prod_{i=1}^T p_i$,其中 $p_i$ 为两两不同的质数,且 $p_i\equiv 3\pmod{4}$ (15分)
  5. $n< 2^{300}$,$n=\prod_{i=1}^T p_i$,其中 $p_i$ 为两两不同的质数 (15分)
  6. $n< 2^{300}$ (25分)
  7. 无特殊限制 (15分)

保证每个子任务不超过15个测试点,但子任务之间会设置所有可行的依赖关系。

高精度库

我们在下发文件中提供了题面中提到的“祖传高精度整数运算库”,可以详见下发文件中的文档。

About Issues

We understand that our problem archive is not perfect. If you find any issues with the problem, including the statement, scoring configuration, time/memory limits, test cases, etc.

You may use this form to submit an issue regarding the problem. A problem moderator will review your issue and proceed it properly.

STOP! Before you submit an issue, please READ the following guidelines:

  1. This is not a place to publish a discussion, editorial, or requests to debug your code. Your issue will only be visible by you and problem moderators. Other users will not be able to view or reply your issues.
  2. Do not submit duplicated issues. If you have already submitted one, please wait for an moderator to review it. Submitting multiple issues will not speed up the review process and might cause your account to be banned.
  3. Issues must be filed in English or Chinese only.
  4. Be sure your issue is related to this problem. If you need to submit an issue regarding another problem, contest, category, etc., you should submit it to the corresponding page.

Active Issues 0

No issues in this category.

Closed/Resolved Issues 0

No issues in this category.