목록공부/Problem Solving (33)
변명은 만개 결과는 한개
https://www.acmicpc.net/problem/2231 2231번: 분해합 문제 어떤 자연수 N이 있을 때, 그 자연수 N의 분해합은 N과 N을 이루는 각 자리수의 합을 의미한다. 어떤 자연수 M의 분해합이 N인 경우, M을 N의 생성자라 한다. 예를 들어, 245의 분해합은 256(=245+2+4+5)이 된다. 따라서 245는 256의 생성자가 된다. 물론, 어떤 자연수의 경우에는 생성자가 없을 수도 있다. 반대로, 생성자가 여러 개인 자연수도 있을 수 있다. 자연수 N이 주어졌을 때, N의 가장 작은 생성자를 구해내는 프로그 www.acmicpc.net 악 넘 잼서 #include void rec(int i, int count, int num[]) { int m_i = i; if (coun..
#include #include using namespace std; int n = 0; int a[25][25]; int d[25][25] = { 0, }; int dx[] = { 1,-1,0,0 };// 대각선일 경우 -1, -1, 1, 1 추가 int dy[] = { 0,0,1,-1 };// 대각선일 경우 -1, 1, -1, 1 추가 void bfs(int x, int y, int cnt) { queue q; q.push(make_pair(x, y)); d[x][y] = cnt; while (!q.empty()) { x = q.front().first; y = q.front().second; q.pop(); for (int k = 0; k < 4; k++) {// 하, 상, 우, 좌 . x++ 는 ..
2 1 0 0 1 1 0 1 0 1 0 1 2 0 0 1 1 0 1 0 0 0 1 0 0 0 1 0 0 0 0 0 0 1 1 0 1 0 0 0 0 0 0 1 0 0 0 0 0 요런식의 배열 입력받을 때 아래처럼 받아주면 됨! 세로 n, 가로 m 일때! labMap 은 가능한 배열크기 +1 혹은 배열크기 딱 맞게 미리 잡아주자 ex ) n = 7, m = 8 int labMap[8][9] for (int i = 0; i < n; i++) { for (int j = 0; j < m; j++) { scanf_s("%d", &labMap[i][j]); } }
https://www.acmicpc.net/problem/11721 11721번: 열 개씩 끊어 출력하기 첫째 줄에 단어가 주어진다. 단어는 알파벳 소문자와 대문자로만 이루어져 있으며, 길이는 100을 넘지 않는다. 길이가 0인 단어는 주어지지 않는다. www.acmicpc.net #include #include #include using namespace std; int main() { char num[100] = { 0, }; scanf("%s", num); int a = strlen(num) / 10; int b = strlen(num) % 10; int total = 0; for (int i = 0; i < a; i++) { for (int j = 0; j < 10; j++) { ..
https://www.acmicpc.net/problem/11720 11720번: 숫자의 합 첫째 줄에 숫자의 개수 N (1 ≤ N ≤ 100)이 주어진다. 둘째 줄에 숫자 N개가 공백없이 주어진다. www.acmicpc.net #include #include using namespace std; int main() { int N, result=0; char num[100] = { 0, }; scanf("%d", &N); scanf("%s", num); for (int i = 0; i < N; i++) { result += num[i] - '0'; } printf("%d", result); return 0; } 너무졸리다
https://www.acmicpc.net/problem/8393 8393번: 합 문제 n이 주어졌을 때, 1부터 n까지 합을 구하는 프로그램을 작성하시오. 입력 첫째 줄에 n (1 ≤ n ≤ 10,000)이 주어진다. 출력 1부터 n까지 합을 출력한다. 예제 입력 1 복사 3 예제 출력 1 복사 6... www.acmicpc.net #include #include using namespace std; int main() { int n, total = 0; cin >> n; for (int i = 1; i < n+1; i++) { total += i; } printf("%d", total); return 0; } 시간이읍서..
https://www.acmicpc.net/problem/1924 1924번: 2007년 첫째 줄에 빈 칸을 사이에 두고 x(1≤x≤12)와 y(1≤y≤31)이 주어진다. 참고로 2007년에는 1, 3, 5, 7, 8, 10, 12월은 31일까지, 4, 6, 9, 11월은 30일까지, 2월은 28일까지 있다. www.acmicpc.net #include #include using namespace std; int main() { int M, D; cin >> M >> D; int date365 = 0; for (int i = 1; i < M; i++) { if (i == 1 || i == 3 || i == 5 || i == 7 || i == 8 || i == 10 || i == 12 ) ..
https://www.acmicpc.net/problem/2441 2441번: 별 찍기 - 4 첫째 줄에는 별 N개, 둘째 줄에는 별 N-1개, ..., N번째 줄에는 별 1개를 찍는 문제 하지만, 오른쪽을 기준으로 정렬한 별(예제 참고)을 출력하시오. www.acmicpc.net #include #include using namespace std; int main() { int N; cin >> N; for (int i = 0; i 1...