PS/Baekjoon Online Judge

[백준 03554] Enigmatic Device [Java]

kimyoungrok 2023. 12. 1. 01:05

문제

Yes, it happened! The first contact! Aliens will visit the Earth in 2010! And they promised to bring an enigmatic device which cannot be constructed using existing Earth technologies. Most of the scientists of the world think so! All newspapers already published their leading articles about it. 

The amazing thing about this device is that it is able to perform 50,000 operations of this kind with a sequence of 50,000 numbers within 3 seconds. Nobody could do it before!

But Roman does not believe in aliens and thinks that it is only a great hoax made by somebody just to win another million bucks on the stock exchange. His goal is to prove this. So he hired you to write a program to simulate this device.

 

입력

출력

For each operation of the second kind, write their output on the separate line, in order they appear in the input.

 


풀이

입력받은 정수 배열에 대해 아래와 같이 계산 후 결과를 출력하는 문제다.

  • k == 1, arr[l] ~ arr[r]의 모든 요소에 대해 arr[i]^2 mod 2010 대입
  • k == 2, arr[l] ~ arr[r]의 합을 출력.


소스코드

보기


출처

 

3554번: Enigmatic Device

The first line of the input contains the length of the sequence $n$ ($1\le n\le 50\,000$). The second line contains $n$ numbers $a_i$ forming the initial sequence ($0\le a_i\le 2009$). The third line contains the number of operations $m$ ($1\le m\le 50\,00

www.acmicpc.net

'PS > Baekjoon Online Judge' 카테고리의 다른 글

[백준 04388] 받아올림 [Java]  (0) 2023.12.03
[백준 04084] Viva la Diferencia [Java]  (1) 2023.12.02
[백준 03578] Holes [Java]  (1) 2023.12.01
[백준 03533] Explicit Formula [Java]  (0) 2023.11.29
[백준 03512] Flat [Java]  (0) 2023.11.27