Conversation
bsa0322
approved these changes
Sep 27, 2021
Comment on lines
+8
to
+19
| int triangle(int t, int* tri){ | ||
|
|
||
| for(int i=0; i<45; i++){ | ||
| for(int j=0; j<45; j++){ | ||
| for(int k=0; k<45; k++){ | ||
| if(tri[i] + tri[j] + tri[k] == t) | ||
| return 1; | ||
| } | ||
| } | ||
| } | ||
| return 0; | ||
| } |
Comment on lines
+25
to
+30
| int start = 1; | ||
| int tri[45]; | ||
| for(int i=2; i<47; i++){ | ||
| tri[i-2] = start; | ||
| start += i; | ||
| } |
There was a problem hiding this comment.
p3. n까지의 합이라는 걸 활용해서 삼각수 잘 구해주셨어요! 👍👍👍 tri[1] = 1을 넣고, i를 지금처럼 2부터 tri[i] += tri[i-1] + i 로 구현하면 코드가 더 깔끔해질 것 같아요!
Comment on lines
+17
to
+53
| void moveRobot(vector<int> &durab, int up, int down, vector<bool> &robot, int n){ | ||
| if(down>up){ | ||
| for(int i=down-1; i>up; i--){ | ||
| if(durab[i+1] > 0 && robot[i] && !robot[i+1]){ | ||
| robot[i] = false; | ||
| robot[i+1] = true; | ||
| durab[i+1]--; | ||
| } | ||
| robot[down] = false; | ||
| } | ||
| } | ||
| else if(down<up){ | ||
| for(int i=down-1; i>=0; i--){ | ||
| if(durab[i+1] > 0 && robot[i] && !robot[i+1]){ | ||
| robot[i] = false; | ||
| robot[i+1] = true; | ||
| durab[i+1]--; | ||
| } | ||
| robot[down] = false; | ||
| } | ||
| for(int i=2*n-1; i>up; i--){ | ||
| if(i==2*n-1){ | ||
| if(durab[0] > 0 && robot[i] && !robot[0]){ | ||
| robot[i] = false; | ||
| robot[0] = true; | ||
| durab[0]--; | ||
| } | ||
| } | ||
| else if(durab[i+1] > 0 && robot[i] && !robot[i+1]){ | ||
| robot[i] = false; | ||
| robot[i+1] = true; | ||
| durab[i+1]--; | ||
| } | ||
| robot[down] = false; | ||
| } | ||
| } | ||
| } |
There was a problem hiding this comment.
p2. 같은 연산이 많이 중복되고 있네요!! 지금 up, down 관계가 여러 경우가 있어서 이렇게 해 주신 것 같아요. 하지만 이 부분은 하나의 반복문으로 합칠 수 있어요. moveBelt 함수에서 인덱스를 관리해주신 것처럼 접근할 수 있지 않을까요? 반복문은 꼭 for문만 있는 건 아니죠.
Comment on lines
+35
to
+45
| for(int i=0; i<8001; i++){ | ||
| if(mode[i] > k){ | ||
| k = mode[i]; | ||
| index = i; | ||
| count = 0; | ||
| } | ||
| else if(mode[i] == k && count<1){ | ||
| count++; | ||
| index = i; | ||
| } | ||
| } |
Comment on lines
+20
to
+24
| if(t > max) | ||
| max = t; | ||
| if(t < min) | ||
| min = t; | ||
| mid[i] = t; |
There was a problem hiding this comment.
p3. 아래서 mid배열의 정렬이 이루어지네요! 그럼 꼭 max, min값 따로 변수로 구해야 할까요?
| l = area/i; | ||
| } | ||
| int temp = (w-1)*2+(l-1)*2; | ||
| if(temp == r && area-temp == b){ |
There was a problem hiding this comment.
p2. 앞의 조건을 만족시킨다면, 뒤의 조건은 무조건 어떻게 되나요?
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.