tlsdltkr1026   2년 전

예제는 다 맞는데 왜 틀린지 모르겠습니다 ㅜㅜ

seawon0808   2년 전

반례입니다.

tlsdltkr1026   2년 전

9행 scanf 에서 1, 1, 1, 1, 1, 1, 1, 1, 1, 41을 입력했을 때,  10행에서 %42을 해줌으로 

각각 나머지는 1, 1, 1, 1, 1, 1, 1, 1, 1, 41나온다.

그럼 i가 0일 때, input[i]=1, input[j]=1, 1, 1, 1, 1, 1, 1, 1, 41 이고, 

이 때 (16행)if문으로 같은 숫자가 나올 때 -1을 해준다.

input[0]=input[1]의 값이 같으므로 count-=1을 해준다.

반복하면,

input[0]==input[1], count-=1, count==9

input[1]==input[2], count-=1, count==8

input[2]==input[3], count-=1, count==7

input[3]==input[4], count-=1, count==6

input[4]==input[5], count-=1, count==5

input[5]==input[6], count-=1, count==4

input[6]==input[7], count-=1, count==3

input[7]==input[8], count-=1, count==2

input[8]!=input[9], count-=1, count==2 

...

제가 아직 조건문을 이해를 못한건지,, 입력한것과 결과값이 다르네요.. 

어디가 어떻게 문제인지 잘 몰르겠어요 ㅜㅜ

seawon0808   2년 전

i, j는 (0, 1), (1, 2), (2, 3) 의 값으로 변하지 않고 (0, 0), (0, 1),(0, 2) ... (0, 9)

(1, 0), (1, 1),(1, 2) ... (1, 9)

(2, 0), (2, 1),(2, 2) ... (2, 9)

...

(9, 0), (9, 1),(9, 2) ... (9, 9)

로 변합니다.

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