[백준] #11720 필요없는 input 날리기 python https://www.acmicpc.net/problem/11720 11720번: 숫자의 합 첫째 줄에 숫자의 개수 N (1 ≤ N ≤ 100)이 주어진다. 둘째 줄에 숫자 N개가 공백없이 주어진다. www.acmicpc.net input으로 들어오지만 필요 없다면 따로 저장하지 않았다. input() num_l = input() result = 0 for i in num_l: result += int(i) print(result) Programming/Algorithm 2022.12.22
[TIL] 2022.12.21. [겨울방학 기록] 2022년 12월 21일 수요일 12/21 2022 🏃 TIL 🏃 오늘은 대체적으로 코딩을 한 것 같다. 웹 프로그래밍 - 데모 ======= real 종강 ======= 백준 문제 풀이 내일은 헬스장도 가고 머신러닝 강의도 들어야지. Today I Learned(TIL) 2022.12.21
[백준] #1065 한수 python https://www.acmicpc.net/problem/1065 1065번: 한수 어떤 양의 정수 X의 각 자리가 등차수열을 이룬다면, 그 수를 한수라고 한다. 등차수열은 연속된 두 개의 수의 차이가 일정한 수열을 말한다. N이 주어졌을 때, 1보다 크거나 같고, N보다 작거나 www.acmicpc.net 한수가 무엇인지 처음 알게 되었다 ! N = int(input()) cnt = 0 for i in range(N+1): if len(str(i)) == 1 and i > 0: cnt += 1 if len(str(i)) == 2: cnt += 1 else: tmp_val = 0 tmp_li = [] for j in range(len(list(str(i)))-1): tmp_li.append(int(lis.. Programming/Algorithm 2022.12.21
[백준] #4673 셀프 넘버 python https://www.acmicpc.net/problem/4673 4673번: 셀프 넘버 셀프 넘버는 1949년 인도 수학자 D.R. Kaprekar가 이름 붙였다. 양의 정수 n에 대해서 d(n)을 n과 n의 각 자리수를 더하는 함수라고 정의하자. 예를 들어, d(75) = 75+7+5 = 87이다. 양의 정수 n이 주어졌을 때, www.acmicpc.net 입력 없이 해보는 백준 문제는 또 처음인 것 같다 ! result_li = [i for i in range(1,10000)] tmp_li = [] for i in range(1,10000): tmp_val = 0 for j in str(i): tmp_val += int(j) tmp_val += i if tmp_val < 10000: tmp_li.a.. Programming/Algorithm 2022.12.21
[백준] #4344 평균은 넘겠지 python https://www.acmicpc.net/problem/4344 4344번: 평균은 넘겠지 대학생 새내기들의 90%는 자신이 반에서 평균은 넘는다고 생각한다. 당신은 그들에게 슬픈 진실을 알려줘야 한다. www.acmicpc.net 소숫점 처리 방법을 배웠다 ! print(f"{}") 방법도 있지만, .format 방법이나 round도 있음을 알았다. N = int(input()) for _ in range(N): num_list = list(map(int, input().split())) rate = num_list[0] result_val = 0 for i in range(1,len(num_list)): result_val += num_list[i] result_tmp = result_val/rat.. Programming/Algorithm 2022.12.21
[백준] #8958 OX퀴즈 python https://www.acmicpc.net/problem/8958 8958번: OX퀴즈 "OOXXOXXOOO"와 같은 OX퀴즈의 결과가 있다. O는 문제를 맞은 것이고, X는 문제를 틀린 것이다. 문제를 맞은 경우 그 문제의 점수는 그 문제까지 연속된 O의 개수가 된다. 예를 들어, 10번 문제의 점수 www.acmicpc.net OX퀴즈 문제. 값을 저장해 두는 게 중요하다고 생각한다. N = int(input()) OX_li = [] for i in range(N): OX_li.append(input()) result_li = [] for i in OX_li: cnt = 0 result_val = 0 for j in i: if j == "O": cnt += 1 elif j == "X": cnt = 0.. Programming/Algorithm 2022.12.21
[백준] #5597 과제 안 내신 분..? python https://www.acmicpc.net/problem/5597 5597번: 과제 안 내신 분..? X대학 M교수님은 프로그래밍 수업을 맡고 있다. 교실엔 학생이 30명이 있는데, 학생 명부엔 각 학생별로 1번부터 30번까지 출석번호가 붙어 있다. 교수님이 내준 특별과제를 28명이 제출했는데, www.acmicpc.net python으로 최대한 짧게 짜는 것을 도전 중이다. num_li = [i for i in range(1,31)] for i in range(28): num_li.remove(int(input())) for i in num_li: print(i) Programming/Algorithm 2022.12.21
[백준] #1110 std::stoi c++ c++에서 std::string을 int로 변환하는 함수를 발견했다. std::stoi(변환할 std::string) 형식으로 하면 된다. 이외에도 std::stol(), std::stod(), std::stof() 의 함수들도 존재한다. #include int main() { std::ios_base::sync_with_stdio(false); int init, N; int count = 0; std::cin >> init; N = init; do { N = (N % 10) * 10 + ((N / 10) + (N % 10)) % 10; count++; } while (init != N); std::cout Programming/Algorithm 2022.12.21
[백준] #10951 문자 개수 모를 때 입력 받기 c++ https://www.acmicpc.net/problem/10951 10951번: A+B - 4 두 정수 A와 B를 입력받은 다음, A+B를 출력하는 프로그램을 작성하시오. www.acmicpc.net 백준 문자열 개수를 모를 때 입력 받는 방법은 다음과 같다. #include int main() { int a,b; while (std::cin >> a >> b) { std::cout Programming/Algorithm 2022.12.21
[백준] #10952 while(true) c++ 이제 백준을 C++로 풀어보기로 하였다. 오늘부터 새로운 마음으로 시작해보자. https://www.acmicpc.net/problem/10952 10952번: A+B - 5 두 정수 A와 B를 입력받은 다음, A+B를 출력하는 프로그램을 작성하시오. www.acmicpc.net while 문으로 문제를 풀이하였다. using namespace는 사용하지 않는다. #include int main() { int a, b; while(true){ std::cin >> a >> b; if(a == 0 and b == 0){ break; } std::cout Programming/Algorithm 2022.12.21