From c3743b563b5330c6f441d29239ff0775a43143e0 Mon Sep 17 00:00:00 2001 From: songyc macbook Date: Sun, 26 Oct 2025 17:10:15 +0900 Subject: [PATCH] 20251026 baekjoon --- code_study/Baekjoon/c/2420.c | 9 ++++ code_study/Baekjoon/java/_2420.java | 11 +++++ code_study/Baekjoon/python/2420.py | 1 + code_study/Baekjoon/swift/11779.swift | 65 +++++++++++++++++++++++++++ code_study/Baekjoon/swift/2420.swift | 5 +++ code_study/Baekjoon/ts/2420.ts | 5 +++ 6 files changed, 96 insertions(+) create mode 100644 code_study/Baekjoon/c/2420.c create mode 100644 code_study/Baekjoon/java/_2420.java create mode 100644 code_study/Baekjoon/python/2420.py create mode 100644 code_study/Baekjoon/swift/11779.swift create mode 100644 code_study/Baekjoon/swift/2420.swift create mode 100644 code_study/Baekjoon/ts/2420.ts diff --git a/code_study/Baekjoon/c/2420.c b/code_study/Baekjoon/c/2420.c new file mode 100644 index 0000000..7c550ea --- /dev/null +++ b/code_study/Baekjoon/c/2420.c @@ -0,0 +1,9 @@ +#include +#include + +int main() { + long long a, b; + scanf("%lld %lld",&a, &b); + printf("%lld\n",llabs(a-b)); + return 0; +} \ No newline at end of file diff --git a/code_study/Baekjoon/java/_2420.java b/code_study/Baekjoon/java/_2420.java new file mode 100644 index 0000000..87fb13f --- /dev/null +++ b/code_study/Baekjoon/java/_2420.java @@ -0,0 +1,11 @@ +import java.util.*; + +public class _2420 { + public static void main(String[] args) { + Scanner sc = new Scanner(System.in); + long a = sc.nextLong(); + long b = sc.nextLong(); + System.out.println(Math.abs(a-b)); + sc.close(); + } +} \ No newline at end of file diff --git a/code_study/Baekjoon/python/2420.py b/code_study/Baekjoon/python/2420.py new file mode 100644 index 0000000..82e1337 --- /dev/null +++ b/code_study/Baekjoon/python/2420.py @@ -0,0 +1 @@ +print(abs((lambda n: n[0]-n[1])(list(map(int, input().split()))))) \ No newline at end of file diff --git a/code_study/Baekjoon/swift/11779.swift b/code_study/Baekjoon/swift/11779.swift new file mode 100644 index 0000000..7fd4a3a --- /dev/null +++ b/code_study/Baekjoon/swift/11779.swift @@ -0,0 +1,65 @@ +if let n = Int(readLine() ?? ""), + let m = Int(readLine() ?? "") +{ + var graph: [[(v: Int, w: Int)]] = Array(repeating: [], count: n+1) + + for _ in 0.. distance[current.now] + next.w { + distance[next.v] = distance[current.now] + next.w + prev[next.v] = current.now + qu.append((now: next.v, distance: distance[next.v])) + } + } + } + + var path: [Int] = [] + path.append(end) + + while true { + let temp = path[path.count-1] + if prev[temp] == 0 { + break + } + path.append(prev[temp]) + } + + path.reverse() + + print(distance[end]) + print(path.count) + print(path.map({String($0)}).joined(separator: " ")) + } +} diff --git a/code_study/Baekjoon/swift/2420.swift b/code_study/Baekjoon/swift/2420.swift new file mode 100644 index 0000000..b6594d8 --- /dev/null +++ b/code_study/Baekjoon/swift/2420.swift @@ -0,0 +1,5 @@ +if let input = readLine(), + let nums = input.split(separator: " ").map({Int64($0)}) as? [Int64] +{ + print(abs(nums[0]-nums[1])) +} \ No newline at end of file diff --git a/code_study/Baekjoon/ts/2420.ts b/code_study/Baekjoon/ts/2420.ts new file mode 100644 index 0000000..37a0ff4 --- /dev/null +++ b/code_study/Baekjoon/ts/2420.ts @@ -0,0 +1,5 @@ +export {}; +console.log(Math.abs(require("fs").readFileSync(0) + .toString().trim().split(" ").map(Number) + .reduce((acc,v,i) => i===0 ? acc-v : acc+v,0) +)); \ No newline at end of file