목록코딩테스트 (73)
bdfgdfg
#include #include using namespace std; int solution(int n) { int answer = 0; int nCount = 0,nextNumCount = 0; int temp = n,nextNum = n; while(temp > 0) { if(temp % 2 == 1) ++nCount; temp /= 2; } int i = 0; while(true) { if(nCount == nextNumCount) { answer = nextNum; break; } else nextNumCount = 0; nextNum++; temp = nextNum; while(temp > 0) { if(temp % 2 == 1) ++nextNumCount; temp /= 2; } ++i; } ..
#include using namespace std; int main() { int hour, minute, second,timeSecond; cin >> hour >> minute >> second; cin >> timeSecond; while (true) { if (timeSecond < 3600) break; timeSecond -= 3600; hour += 1; if (hour == 24) hour = 0; } while (true) { if (timeSecond < 60) break; timeSecond -= 60; minute += 1; if (minute == 60) { hour += 1; if (hour == 24) hour = 0; minute = 0; } } second += timeS..
#include #include #include using namespace std; int solution(vector land) { int answer = 0; int yLen = land.size(),y,x; for(y = 1; y < yLen; ++y) { land[y][0] += max({land[y - 1][1],land[y - 1][2],land[y - 1][3]}); land[y][1] += max({land[y - 1][0],land[y - 1][2],land[y - 1][3]}); land[y][2] += max({land[y - 1][0],land[y - 1][1],land[y - 1][3]}); land[y][3] += max({land[y - 1][0],land[y - 1][1],..
#include #include #include using namespace std; bool solution(string s) { bool answer = true; stack st; int len = s.size(); if (s[0] == ')') return false; for (int i = 0; i < len; ++i) { if (s[i] == ')') { if (!st.empty() && st.top() == '(') st.pop(); else st.push(s[i]); } else st.push(s[i]); } if (!st.empty()) answer = false; return answer; }