백준 10

C

[BOJ 2606] S3 바이러스 C++

바이러스 난이도: Silver 3 번호: 2606 알고리즘 분류: 그래프 이론, 그래프 탐색, 깊이 우선 탐색, 너비 우선 탐색 언어: C++ 2606번: 바이러스 C++ #include using namespace std; int N, P; // 컴퓨터가 최대 100개 이므로 path도 최대 100 * 100 bool path[101][101]; bool visited[101]; void DFS(int S) { visited[S] = true; for (int i = 1; i sync_with_stdio(0); cout.tie(0); cin >> N >> P; for (int i = 0; i > a >> b; path[a][b] = true; path[b..

Algorithm/BOJ 2023.02.07

C

[ BaekJoon - Python & Java ] 단계별로 풀기 3. For

단계별로 풀기 - 3. for 2749 곱셈 n = int(input()) a = 1 while a < 10: print(f"{n} * {a} = {n * a}") a += 1 import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int j = sc.nextInt(); for(int i = 1; i < 10; i++){ System.out.println(j + " * " + i + " = " + j * i); } sc.close(); } } 10950 A + B - 3 n = int(input()) while n != 0: a, b = m..

Algorithm/BOJ 2021.12.09

C

[ Python ] 입출력(I/O) 속도 빠르게 하기

백준 파이썬 문제를 풀다보면 시간초과가 뜨는 경우 입출력 방법을 바꿔줌으로써 해결하는 방법이 있다. import sys input = sys.stdin.readline print = sys.stdout.write 위 처럼 input()과 print()를 덮어씌워버린다. # 주의할 점 바꾸고 나면, input()은 개행문자 "\n"까지 읽어들이기 때문에 .rstrip()등으로 지워주어야 하고 import sys input = sys.stdin.readline n = input() # "1"을 입력 할 때, print(list(n)) # ['1', '\n'] print([int(n)]) # [1] print(list(n.rstrip())) # ['1'] print()는 출력 방식이 다음과 같이 바뀌어 버린다..

Dev/Python 2021.12.06

C

[ BaekJoon - Python ] 단계별로 풀기 1. 출력 입출력 (I/O)

단계별로 풀기 - 1. 입출력 # 참조 링크 파이썬으로 정수 입력 받기 1000번 A + B a, b = map(int, input().split()) print(a+b) 1001번 A - B a, b = map(int, input().split()) print(a - b) 10998번 A * B a, b = map(int, input().split()) print(a * b) 1008번 A / B a, b = map(int, input().split()) print(a/b) 10869번 사칙연산 a, b = map(int, input().split()) print(a+b) print(a-b) print(a*b) print(int(a/b)) print(a % b) 10430 나머지 a, b, c = ma..

Algorithm/BOJ 2021.11.30