Algorithm/BOJ 기초 (19) 썸네일형 리스트형 [백준] 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 [백준] 주사위 세개 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 [백준] 소인수분해 11653 Python C++ Python 1 2 3 4 5 6 7 8 9 N = int(input()) summ = 0 i = 0 while summ [백준] 문자열 반복 2675 C++ 123456789101112131415161718192021222324252627282930#include #include #include using namespace std; int main() { string str_T; getline(cin, str_T); int int_T; int_T = stoi(str_T); int temp_range; string a; for (int i = 0; i 이전 1 2 3 다음