본문 바로가기

프로그래밍

(56)
(파이썬) 백준 알고리즘 1316번 그룹 단어 체커 문제풀이 (Python) 12345678910111213141516171819cnt = 0;N = int(input())for i in range(N): check= [0]*26 flag = 1; word = input() n = len(word) for j in range(n): if check[ord(word[j])- 97]: if word[j] != word[j-1]: flag = 0; break check[ord(word[j])-97] = 1 check = [0]*26 if flag: cnt +=1print(cnt)cs문제 출처https://www.acmicpc.net/problem/1316
(C++) 백준 알고리즘 1074번 Z 문제풀이 (C++) 123456789101112131415161718192021222324252627282930#include #include using namespace std; int N, r, c, cnt; void recursion(int row, int col, int range){ if (row == r && col == c){ cout N >> r >> c; recursion(0, 0, pow(2, N)); return 0;}Colored by Color Scriptercs example 문제 출처https://www.acmicpc.net/problem/1074
(C++) 백준 알고리즘 7576번 토마토 문제풀이 (C++) 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081#include #include #include using namespace std; bool check[1003][1003] = {false,};int dist[1003][1003];int box[1003][1003];int dx[] = {0,0,1,-1};int dy[] = {1,-1,0,0}; int main(){ int M, N; int i,j; scanf("%d %d",&M,&N); for(i = 0; i
(C언어) 백준 알고리즘 1157번 단어 공부 문제풀이 (C언어) 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758#include #include #include #define MAX 1000000 void upper(char *str); int alpha[26] = {0,}; int main(){ char word[MAX]; int i, index; int max = 0; int flag = 0; int len; scanf("%s", word); upper(word); len = strlen(word); for(i = 0; i
(파이썬) 백준 알고리즘 2675번 문자열 반복 문제풀이 (Python) 1234567T = int(input()) for i in range(T): R, S = input().split() for k in S: print(k*int(R), end='') print()cs문제 출처https://www.acmicpc.net/problem/2675
(파이썬) 백준 알고리즘 10809번 알파벳 찾기 문제풀이 (Python) 1234567891011S = input()check = [-1]*26 for i in range(len(S)): if check[ord(S[i])-97] != -1: continue else: check[ord(S[i])-97] = i for i in range(26): print(check[i], end=' ')cs소문자 a는 아스키코드로 97이다.문자를 아스키코드로 변환하여 97을 뺀 인덱스에 문자열 위치를 입력해준다.ex a=97 이므로 97-97 = 0 이여서 check[0]에 문자열의 위치 i를 넣어준다. 문제 출처https://www.acmicpc.net/problem/10809
(파이썬) 백준 알고리즘 2839번 설탕 배달 문제풀이 (Python) 1234567891011121314151617181920212223n = int(input())# 초기화five = 0three = 0 # 최대 5kg의 갯수와 나머지를 구한다.five = n//5b = n%5 # 나머지가 0이 아니면 3kg 갯수를 구한다.if b !=0: while five >= 0: if b%3 == 0: three = b//3 break five -= 1 b += 5 ret=five + three if ret
(파이썬) 백준 알고리즘 4673번 셀프 넘버 문제풀이 (Python) 123456789101112131415161718192021def self_num(x): a = int(x) if a > 10000: return else: for j in range(len(x)): a += int(x[j]) if a > 10000: return check[a] = True self_num(str(a)) check = [False]*10001 for i in range(1, 10000): self_num(str(i)) for i in range(1, 10000): if check[i] ==False: print(i) Colored by Color Scriptercs1 ~ 11 : 셀프 넘버가 아니면 해당하는 값의 check 인덱스에 True 값을 주는 함수이다...