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

6992번 - Arithmetic Sequence 다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
1 초 128 MB25515913164.216%

문제

bilTo pass time during their long trek through the misty mountains and to prepare for the ordeals ahead, Gandalf starts teaching Math to Bilbo and the thirteen dwarves. One of the things he teaches them is the notion of an arithmetic sequence. A sequence of numbers, x1, ..., xn, is an arithmetic sequence if the differences between successive terms in the sequence are the same. In other words, the sequence is an arithmetic sequence if: x2 - x1 = x3 - x2 = ... = xn - xn-1.

Bilbo and Ori, one of the dwarves, start playing a game to develop their skills. One of them suggests a sequence of numbers, and the other has to quickly tell whether the sequence is an arithmetic sequence, and if yes, then he also has to list the next 5 numbers in the sequence. You are to write a program to help them make sure their answers are correct.

입력

The first line in the test data file contains the number of test cases (< 100). After that, each line contains one test case: the first number is the number of entries, n, in the sequence (provided as an int), and the next n numbers are the sequence itself.

출력

For each test case, you are to either output that the sequence is not an arithmetic sequence, or you are to output the next 5 numbers in the sequence. The exact format is shown below in the examples.

제한

출력 형식

정확한 출력 형식은 제출에서 언어를 Java로 설정하면 확인할 수 있다.

예제 입력 1

3
3 1 2 3
5 4 8 12 16 20
4 1 2 3 5

예제 출력 1

The next 5 numbers after [1, 2, 3] are: [4, 5, 6, 7, 8]
The next 5 numbers after [4, 8, 12, 16, 20] are: [24, 28, 32, 36, 40]
The sequence [1, 2, 3, 5] is not an arithmetic sequence.

힌트

출처

School > University of Maryland High School Programming Contest > HSPC 2013 연습 세션 P1번

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

출처

대학교 대회

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

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