본문 바로가기

분류 전체보기

(82)
[백준] 2581 소수 Python (주어진 범위 내 소수들의 합, 최소값) 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 m = int(input()) n = int(input()) lists = [] for i in range(m, n+1): check = 0 if i >= 2: if i == 2: lists.append(i) else: for j in range(2, i): if i%j == 0: check = 1 break if check == 0: lists.append(i) if len(lists) >= 1: print(sum(lists)) print(min(lists)) else: print(-1)
[백준] 소수찾기 1978 Python C++ Python 1234567891011121314151617tc = int(input())inputs = list(map(int, input().strip().split()))cnt = 0 for i in inputs: nop = 0 if i>=2: if i == 2: cnt +=1 else: for j in range(2,i): if i%j == 0: nop = 1 break if nop == 0: cnt +=1print(cnt)Colored by Color Scriptercs C++ 1234567891011121314151617181920212223242526272829303132333435#include using namespace std; int main(){ int n; int tc; cin >>..
[백준] 2921 도미노 Python 123456789101112n = int(input())a = [0,0]summ = 0 while a[0] != n: if a[0] == a[1]: a[1] += 1 a[0] = 0 summ += (a[0]+a[1]) a[0] +=1 summ += (a[0] + a[1])print(summ)cs
LOS (Lord Of SQL Injection) Clear 작년 5월이였나... Clear를 하고 해당 게시글에 하나씩 풀이 방법에 대한 소스코드를 올린다했는데 뒤늦게 작성이 안된 것을 깨달았다.. 현재 공채로 구직활동을 하고 있어 바쁘지만 알고리즘 공부를 하면서 틈틈이 블로그에 글을 업데이트 하려고 한다. 해당 워게임 사이트를 통해 SQL Injection 공부가 많이 되었던 것으로 기억한다. 해당 URL 말고도 다른 버전의 LOS도 있고 SQL Injection을 할 수 있는 좋은 워게임 사이트들이 있는 것을 알고 있다. 개발 보안 둘다 좋다. 꾸준히 하자...
Python Dictionary Max, Min Key, Value(파이썬 딕셔너리, 사전 최대 최소 구하기) 1 2 3 4 5 6 dicts = {"c":1, "b":2, "a":3} print("dicts의 최대 값 구하기: {}".format(max(dicts.values()))) print("dicts의 최소 값 구하기: {}".format(min(dicts.values()))) print("dits의 최대 값을 가지는 key 구하기: {}".format(max(dicts, key=dicts.get))) print("dits의 최소 값을 가지는 key 구하기: {}".format(min(dicts, key=dicts.get))) cs
[백준] 주사위 세개 2480 Python C++ Python 1234567891011121314a = list(map(int, input().strip().split())) if a[0] == a[1] == a[2]: print(10000+(a[0]*1000))elif a.count(a[0]) == 2 or a.count(a[1]) == 2 or a.count(a[2]) == 2: if a.count(a[0]) == 2: print(1000 + (a[0] * 100)) elif a.count(a[1]) == 2: print(1000 + (a[1] * 100)) elif a.count(a[2]) == 2: print(1000 + (a[2] * 100))else: print(max(a)*100) Colored by Color Scriptercs C++ 1..
[백준] 최대공약수와 최소공배수 2609 Python C++ (1934 최소공배수 가능) Python 12345678910111213141516# 최대 공약수 - 유클리드# 최소공배수 - 두수의 곱 / 최대공약수def gcd(a, b): mod = a%b while mod != 0: a = b b = mod mod = a%b return b def lcm(a, b): return (a*b) // gcd(a,b) a, b = map(int, input().strip().split()) print(gcd(a,b))print(lcm(a,b))cs C++ 1234567891011121314151617181920212223242526272829#include using namespace std; int gcd(int a, int b){ int mod = a%b; while (mod != 0){ a =..
[백준] 수들의합 1789 Python C++ Python 123456789101112131415161718#include using namespace std; int main() { int i = 0; long sum = 0; long N = 0; scanf("%ld", &N); while (sum