개발자 톡
연습문제 톡
[21년 재직자 대회 예선] 전광판
이게 틀렸다할 반례가 가려져 있어서 전 잘 모르겠네요.
- 등록일
- 2025-01-29 16:17:54
- 조회수
- 14
- 작성자
- itkwon
#include<stdio.h> #include<math.h> const int bulbsToSwitch[11][11] = { {0,4,3,3,4,3,2,2,1,2,6}, {4,0,5,3,2,5,6,2,5,4,2}, {3,5,0,2,5,4,3,5,2,3,5}, {3,3,2,0,3,2,3,3,2,1,5}, {4,2,5,3,0,3,4,2,3,2,4}, {3,5,4,2,3,0,1,3,2,1,5}, {2,6,3,3,4,1,0,4,1,2,6}, {2,2,5,3,2,3,4,0,3,2,4}, {1,5,2,2,3,2,1,3,0,1,7}, {2,4,3,1,2,1,1,2,1,0,6}, {6,2,5,5,4,5,6,4,7,6,0} }; int main() { int t1, nT; freopen("input.txt","r",stdin); // Reopen stdin from input text file scanf("%d", &nT); int numsOnInput[2], t2, t3; int numsOnBoard[2][5]; char breakFor = 0; for(t1=0;t1<nT;t1++) { scanf("%d %d", &numsOnInput[0], &numsOnInput[1]); //Before [0] //After [1] for(t2=0;t2<2;t2++) { for(t3=0;t3<5;t3++) { //numsOnBoard[t2][t3] = (numsOnInput[t2] % (int)pow(10.0,(double)t3+1) - numsOnInput[t2] % (int)pow(10.0,(double)t3)) / (int)pow(10.0, (double)(t3)); int tDPower1, tDPower2; int tIntm4; tDPower1 = (int)pow(10.0, (double)t3+1); tDPower2 = (int)pow(10.0, (double)t3); tIntm4 = (numsOnInput[t2] % tDPower1 - numsOnInput[t2] % tDPower2); numsOnBoard[t2][t3] = tIntm4 / tDPower2; } breakFor = 0; for(t3=4;t3>0;t3--) { if(numsOnBoard[t2][t3] == 0 && numsOnBoard[t2][t3-1] == 0) numsOnBoard[t2][t3]=10; else if (numsOnBoard[t2][t3] == 0 && numsOnBoard[t2][t3-1] != 0) { numsOnBoard[t2][t3]=10; breakFor = 1; break; } else if (numsOnBoard[t2][t3] != 0) { breakFor=1; break; } if(breakFor == 1) break; } } int fSum = 0; for(t2=0;t2<5;t2++) { fSum += bulbsToSwitch[ numsOnBoard[0][t2] ][ numsOnBoard[1][t2] ]; } printf("%d\n", fSum); } return 0; }
이렇게 풀었는데 1-2번 빼고는 다 틀렸다고 나오네요. 혹시 디버깅할 수 있는 반례 같은 것이 있을까요?
#[21년_재직자_대회_예선]_전광판
#c