분류 전체보기(174)
-
백준 바킹독 재귀 모음 - 1629 곱셈,
1629 곱셈 #include #include #include #include using namespace std; long long pow(long long a, long long b , long long c) { //b가 홀수면 , if (b == 1) return a%c; long long val = pow(a, b/2, c); val = val*val%c; if (b%2 == 0) return val; return val * a % c; } int main() { long long a,b,c; cin>>a>>b>>c; cout
2022.09.07 -
소프티어 - H-클린알파
아까 별3개를 풀고 이번엔 별4개를 했다 . 아직까진 무슨 알고리즘을 써야하고 그런건 없이 다 구현이다! 근데 문제가 이해하기 너무 어렵고 더럽다.. 난 이런거 싫은데 #include #include using namespace std; int main(int argc, char** argv) { int p, n; vector corona; cin>>p>>n; long long ans = 0; for(int i = 0; i>tmp; corona.push_back(tmp); ans = ans * p + corona[i]; ans%=1000000007; } cout
2022.09.05 -
소프티어 - 성적평균
이런게 있는지도 몰랐는데 한번 해봤다 현대 갈 때 필요한 거라고 한다! 화욜에 바로 시험인데 어떤게 나올꼬 해서 봤다. 놀랍다 백준느낌이다! 문제 자체는 쉬운데, c++ 에서 정수일 때 50.00 이런식으로 소수점 2자리 출력하는법을 몰랐다. 그래서 걍 printf로 했다 아! #include #include #include #include using namespace std; int main(int argc, char** argv) { int n, k; vector score; cin>>n>>k; for(int i =0; i>tmp; score.push_back(tmp); } for(int i = 0; i< k; i++) { int from, to; long..
2022.09.04 -
프로그래머스 - 성격 유형 검사하기
#include #include #include #include using namespace std; int alpha[105]; string solution(vector survey, vector choices) { string answer = ""; for(int i = 0; i alpha['R']) answer+= 'T'; else answer += 'R'; if(alpha['C'] alpha['J']) answ..
2022.09.03 -
백준 바킹독 BFS 모음 - 1926 그림, 2178 미로탐색, 7576 토마토, 4179 불!
1926번 그림 #include #include #include #include #include using namespace std; int visited[502][502]; int table[502][502]; int maxval = -1; int xcor[4] = { -1, 0, 1, 0}; int ycor[4] = {0, 1, 0, -1}; int main() { int n ,m; cin>>n>>m; for(int i = 0; i >table[i][j]; } } int numpic =0; for(int i = 0; i < n ; i++) { for (int j = 0; j < m; j++) { queue q; if ..
2022.09.03 -
프로그래머스 짝지어 제거하기
프로그래머스 레벨체크 2단계를 통과했다! 좀 쉬운문제들로 2개가 나와서 할 수 있었던 것 같다 기분이 매우 좋노 아ㅋㅋ 이 문제는 그냥 스택에 계속 집어넣으면서 top에 있는 것과 같으면 pop만 잘 시켜주면 된다. 이 아이디어로 풀면 한 케이스가 seg fault가 나오는데, 이는 스택이 비어있는 경우에 st.top()을 참조하려 하기 때문에 일어난다. 그래서 비어있을 때는 그냥 push 해주는 경우만 추가해주면 무리없게 통과할 수 있다!! #include #include #include #include #include using namespace std; int solution(string s) { int answer = -1; stack st; // 그냥 한번씩 계속 돌면서 없애는편이 나을 거 같음..
2022.09.01