CF1091G.New Year and the Factorisation Collaboration

普及/提高-

通过率:0%

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

Integer factorisation is hard. The RSA Factoring Challenge offered $$100,000 for factoring RSA- 10241024 , a 10241024 -bit long product of two prime numbers. To this date, nobody was able to claim the prize. We want you to factorise a 10241024 -bit number.

Since your programming language of choice might not offer facilities for handling large integers, we will provide you with a very simple calculator.

To use this calculator, you can print queries on the standard output and retrieve the results from the standard input. The operations are as follows:

  • + x y where xx and yy are integers between 00 and n1n-1 . Returns (x+y)modn(x+y) \bmod n .
  • - x y where xx and yy are integers between 00 and n1n-1 . Returns (xy)modn(x-y) \bmod n .
  • * x y where xx and yy are integers between 00 and n1n-1 . Returns (xy)modn(x \cdot y) \bmod n .
  • / x y where xx and yy are integers between 00 and n1n-1 and yy is coprime with nn . Returns (xy1)modn(x \cdot y^{-1}) \bmod n where y1y^{-1} is multiplicative inverse of yy modulo nn . If yy is not coprime with nn , then 1-1 is returned instead.
  • sqrt x where xx is integer between 00 and n1n-1 coprime with nn . Returns yy such that y2modn=xy^2 \bmod n = x . If there are multiple such integers, only one of them is returned. If there are none, 1-1 is returned instead.
  • ^ x y where xx and yy are integers between 00 and n1n-1 . Returns xymodn{x^y \bmod n} .

Find the factorisation of nn that is a product of between 22 and 1010 distinct prime numbers, all of form 4x+34x + 3 for some integer xx .

Because of technical issues, we restrict number of requests to 100100 .

输入格式

The only line contains a single integer nn ( 21n2102421 \leq n \leq 2^{1024} ). It is guaranteed that nn is a product of between 22 and 1010 distinct prime numbers, all of form 4x+34x + 3 for some integer xx .

输出格式

You can print as many queries as you wish, adhering to the time limit (see the Interaction section for more details).

When you think you know the answer, output a single line of form ! k p_1 p_2 ... p_k, where kk is the number of prime factors of nn , and pip_i are the distinct prime factors. You may print the factors in any order.

Hacks input

For hacks, use the following format:.

The first should contain kk ( 2k102 \leq k \leq 10 ) — the number of prime factors of nn .

The second should contain kk space separated integers p1,p2,,pkp_1, p_2, \dots, p_k ( 21n2102421 \leq n \leq 2^{1024} ) — the prime factors of nn . All prime factors have to be of form 4x+34x + 3 for some integer xx . They all have to be distinct.

Interaction

After printing a query do not forget to output end of line and flush the output. Otherwise you will get Idleness limit exceeded. To do this, use:

  • fflush(stdout) or cout.flush() in C++;
  • System.out.flush() in Java;
  • flush(output) in Pascal;
  • stdout.flush() in Python;
  • see documentation for other languages.

The number of queries is not limited. However, your program must (as always) fit in the time limit. The run time of the interactor is also counted towards the time limit. The maximum runtime of each query is given below.

  • + x y — up to 11 ms.
  • - x y — up to 11 ms.
  • * x y — up to 11 ms.
  • / x y — up to 350350 ms.
  • sqrt x — up to 8080 ms.
  • ^ x y — up to 350350 ms.

Note that the sample input contains extra empty lines so that it easier to read. The real input will not contain any empty lines and you do not need to output extra empty lines.

输入输出样例

  • 输入#1

    21
    
    7
    
    17
    
    15
    
    17
    
    11
    
    -1
    
    15
    
    

    输出#1

    + 12 16
    
    - 6 10
    
    * 8 15
    
    / 5 4
    
    sqrt 16
    
    sqrt 5
    
    ^ 6 12
    
    ! 2 3 7

说明/提示

We start by reading the first line containing the integer n=21n = 21 . Then, we ask for:

  1. (12+16)mod21=28mod21=7(12 + 16) \bmod 21 = 28 \bmod 21 = 7 .
  2. (610)mod21=4mod21=17(6 - 10) \bmod 21 = -4 \bmod 21 = 17 .
  3. (815)mod21=120mod21=15(8 \cdot 15) \bmod 21 = 120 \bmod 21 = 15 .
  4. (541)mod21=(516)mod21=80mod21=17(5 \cdot 4^{-1}) \bmod 21 = (5 \cdot 16) \bmod 21 = 80 \bmod 21 = 17 .
  5. Square root of 1616 . The answer is 1111 , as (1111)mod21=121mod21=16(11 \cdot 11) \bmod 21 = 121 \bmod 21 = 16 . Note that the answer may as well be 1010 .
  6. Square root of 55 . There is no xx such that x2mod21=5x^2 \bmod 21 = 5 , so the output is 1-1 .
  7. (612)mod21=2176782336mod21=15(6^{12}) \bmod 21 = 2176782336 \bmod 21 = 15 .

We conclude that our calculator is working, stop fooling around and realise that 21=3721 = 3 \cdot 7 .

首页