Logo
(追記) (追記ここまで)

22636번 - Complex Integer Solutions 다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
8 초 (추가 시간 없음) 512 MB4310720.000%

문제

Let f(x) = a0 + a1x + a2x2 + ... + adxd be the function where each ai (0 ≤ id) is a constant integer (and ad is non-zero) and x is a variable. Your task is to write a program that finds all complex integer solutions of the equation f(x) = 0 for a given f(x). Here, by complex integers, we mean complex numbers whose real and imaginary parts are both integers.

입력

The input consists of two lines. The first line of the input contains d, the degree of f(x). The second line contains (d + 1) integers a0, ... , ad, the coeffcients of the equation. You may assume all the following: 1 ≤ d ≤ 10, |ai| ≤ 106 and ad ≠ 0.

출력

There should be two lines in the output. In the first line, print the number m of complex integer solutions. In the second line, print m solutions separated by space. Each solution should be counted and printed exactly once even if it is a multiple root. The solutions should be printed in ascending order of their real parts then their imaginary parts, and in the following fashion: 0, -2, i, -3i, 2+i, and 3-4i.

제한

예제 입력 1

4
-2 0 0 0 2

예제 출력 1

4
-1 -i i 1

예제 입력 2

8
0 0 25 15 17 -10 1 -1 1

예제 출력 2

5
-1-2i -1+2i 0 2-i 2+i

힌트

출처

Contest > ICPC Japanese Alumni Group > JAG Winter Camp > JAG Winter Camp 2009 Day 2 C번

(追記) (追記ここまで)

출처

대학교 대회

  • 사업자 등록 번호: 541-88-00682
  • 대표자명: 최백준
  • 주소: 서울시 서초구 서초대로74길 29 서초파라곤 412호
  • 전화번호: 02-521-0487 (이메일로 연락 주세요)
  • 이메일: contacts@startlink.io
  • 통신판매신고번호: 제 2017-서울서초-2193 호

AltStyle によって変換されたページ (->オリジナル) /