whitetigers   1년 전

입력

15 15

29 28 27 26 25 24 23 22 21 20 19 18 17 16 15

28 27 26 25 24 23 22 21 20 19 18 17 16 15 14

27 26 25 24 23 22 21 20 19 18 17 16 15 14 13

26 25 24 23 22 21 20 19 18 17 16 15 14 13 12

25 24 23 22 21 20 19 18 17 16 15 14 13 12 11

24 23 22 21 20 19 18 17 16 15 14 13 12 11 10

23 22 21 20 19 18 17 16 15 14 13 12 11 10 9

22 21 20 19 18 17 16 15 14 13 12 11 10 9 8

21 20 19 18 17 16 15 14 13 12 11 10 9 8 7

20 19 18 17 16 15 14 13 12 11 10 9 8 7 6

19 18 17 16 15 14 13 12 11 10 9 8 7 6 5

18 17 16 15 14 13 12 11 10 9 8 7 6 5 4

17 16 15 14 13 12 11 10 9 8 7 6 5 4 3

16 15 14 13 12 11 10 9 8 7 6 5 4 3 2

15 14 13 12 11 10 9 8 7 6 5 4 3 2 1

출력

7283079311843703191

https://www.acmicpc.net/board/...의 반례는 다 통과했습니다

seico75   1년 전

{end,} 

이렇게 쓰면 첫 값만 초기화 되지 않나요?

0이외에는...

whitetigers   1년 전

모두 초기화 됩니다.

whitetigers   1년 전

누구 티스토리인지 모르겠지만 틀렸습니다.

정적으로 선언된 배열에는 저렇게 하면 모두 초기화 됩니다.

seico75   1년 전

음, 다른 reference 를 드리면..

https://en.cppreference.com/w/...

Initialization from brace-enclosed lists

When an array is initialized with a brace-enclosed list of initializers, the first initializer in the list initializes the array element at index zero (unless a designator is specified)(since C99), and each subsequent initializer without a designator (since C99)initializes the array element at index one greater than the one initialized by the previous initializer.

int x[] = {1,2,3}; // x has type int[3] and holds 1,2,3
int y[5] = {1,2,3}; // y has type int[5] and holds 1,2,3,0,0
int z[4] = {1}; // z has type int[4] and holds 1,0,0,0
int w[3] = {0}; // w has type int[3] and holds all zeroes

그리고, 코드를 짜봐도 0 이외의 값으로는 초기화가 안되는 것 같습니다.

http://ideone.com/JUu3rl

우리가 서로 다른 이야기를 하고 있는 걸까요?

whitetigers   1년 전

아, arr[i] = {x}; 형식이 된다는게 아니라 arr[i] = {0};이 된다는걸 잘못 이해했었네요.

알려주셔서 감사합니다.

댓글을 작성하려면 로그인해야 합니다.