Pythonmain.py · 27 行import sys def part_fee(t): """하루가 안 되는 t분의 요금.""" if t <= 30: return 0 fee = 2000 if t > 60: fee += (t - 60 + 9) // 10 * 500 # 다 차지 않은 10분도 10분으로: 올림 return min(fee, 20000) lines = sys.stdin.read().split("\n")n = int(lines[0])cars = [line.split() for line in lines[1:n + 1]]out = []for kind, minutes in cars: m = int(minutes) fee = m // 1440 * 20000 + part_fee(m % 1440) if kind == "disabled": fee = fee // 5 # 80% 할인 = 5분의 1 elif kind == "compact": if m <= 1440: # 하루를 넘기면 경차 할인이 없다 fee = fee // 2 out.append(str(fee))print("\n".join(out))
JavaScriptmain.js · 28 行const lines = require("fs").readFileSync(0, "utf8").split("\n"); // 하루가 안 되는 t분의 요금function partFee(t) { if (t <= 30) return 0; let fee = 2000; if (t > 60) { fee += Math.ceil((t - 60) / 10) * 500; // 다 차지 않은 10분도 10분으로 } return Math.min(fee, 20000);} const n = Number(lines[0]);const cars = lines.slice(1, n + 1).map((line) => line.trim().split(/\s+/));const out = [];for (const [kind, minutes] of cars) { const m = Number(minutes); let fee = Math.floor(m / 1440) * 20000 + partFee(m % 1440); if (kind === "disabled") { fee = fee / 5; // 80% 할인. fee는 500의 배수라 나누어떨어진다 } else if (kind === "compact") { if (m <= 1440) { fee = fee / 2; // 하루를 넘기면 경차 할인이 없다 } } out.push(fee);}console.log(out.join("\n"));
TypeScriptmain.ts · 29 行import { readFileSync } from "node:fs";const lines: string[] = readFileSync(0, "utf8").split("\n"); // 하루가 안 되는 t분의 요금function partFee(t: number): number { if (t <= 30) return 0; let fee = 2000; if (t > 60) { fee += Math.ceil((t - 60) / 10) * 500; // 다 차지 않은 10분도 10분으로 } return Math.min(fee, 20000);} const n: number = Number(lines[0]);const cars: string[][] = lines.slice(1, n + 1).map((line) => line.trim().split(/\s+/));const out: number[] = [];for (const [kind, minutes] of cars) { const m: number = Number(minutes); let fee: number = Math.floor(m / 1440) * 20000 + partFee(m % 1440); if (kind === "disabled") { fee = fee / 5; // 80% 할인. fee는 500의 배수라 나누어떨어진다 } else if (kind === "compact") { if (m <= 1440) { fee = fee / 2; // 하루를 넘기면 경차 할인이 없다 } } out.push(fee);}console.log(out.join("\n"));
JavaMain.java · 38 行import java.io.BufferedReader;import java.io.InputStreamReader;import java.io.IOException; public class Main { // 하루가 안 되는 t분의 요금 static int partFee(int t) { if (t <= 30) return 0; int fee = 2000; if (t > 60) { fee += (t - 60 + 9) / 10 * 500; // 다 차지 않은 10분도 10분으로: 올림 } return Math.min(fee, 20000); } public static void main(String[] args) throws IOException { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); int n = Integer.parseInt(br.readLine().trim()); String[] cars = new String[n]; for (int i = 0; i < n; i++) cars[i] = br.readLine().trim(); StringBuilder out = new StringBuilder(); for (String car : cars) { String[] p = car.split("\\s+"); String kind = p[0]; int m = Integer.parseInt(p[1]); int fee = m / 1440 * 20000 + partFee(m % 1440); if (kind.equals("disabled")) { fee = fee / 5; // 80% 할인 = 5분의 1 } else if (kind.equals("compact")) { if (m <= 1440) { fee = fee / 2; // 하루를 넘기면 경차 할인이 없다 } } out.append(fee).append('\n'); } System.out.print(out); }}
C#Main.cs · 46 行using System;using System.Collections.Generic;using System.Text; class Program{ // 하루가 안 되는 t분의 요금 static int PartFee(int t) { if (t <= 30) return 0; int fee = 2000; if (t > 60) { fee += (t - 60 + 9) / 10 * 500; // 다 차지 않은 10분도 10분으로: 올림 } return Math.Min(fee, 20000); } static void Main() { int n = int.Parse(Console.ReadLine().Trim()); var cars = new List<string>(); for (int i = 0; i < n; i++) cars.Add(Console.ReadLine().Trim()); var out_ = new StringBuilder(); foreach (string car in cars) { string[] p = car.Split(' ', StringSplitOptions.RemoveEmptyEntries); string kind = p[0]; int m = int.Parse(p[1]); int fee = m / 1440 * 20000 + PartFee(m % 1440); if (kind == "disabled") { fee = fee / 5; // 80% 할인 = 5분의 1 } else if (kind == "compact") { if (m <= 1440) { fee = fee / 2; // 하루를 넘기면 경차 할인이 없다 } } out_.Append(fee).Append('\n'); } Console.Write(out_); }}
C++main.cpp · 33 行#include <algorithm>#include <iostream>#include <string>#include <utility>#include <vector> // 하루가 안 되는 t분의 요금int partFee(int t) { if (t <= 30) return 0; int fee = 2000; if (t > 60) { fee += (t - 60 + 9) / 10 * 500; // 다 차지 않은 10분도 10분으로: 올림 } return std::min(fee, 20000);} int main() { int n; std::cin >> n; std::vector<std::pair<std::string, int>> cars(n); for (auto& car : cars) std::cin >> car.first >> car.second; for (const auto& [kind, m] : cars) { int fee = m / 1440 * 20000 + partFee(m % 1440); if (kind == "disabled") { fee = fee / 5; // 80% 할인 = 5분의 1 } else if (kind == "compact") { if (m <= 1440) { fee = fee / 2; // 하루를 넘기면 경차 할인이 없다 } } std::cout << fee << '\n'; }}
Cmain.c · 32 行#include <stdio.h>#include <string.h> /* 하루가 안 되는 t분의 요금 */int part_fee(int t) { if (t <= 30) return 0; int fee = 2000; if (t > 60) { fee += (t - 60 + 9) / 10 * 500; /* 다 차지 않은 10분도 10분으로: 올림 */ } return fee < 20000 ? fee : 20000;} int main(void) { int n; scanf("%d", &n); for (int i = 0; i < n; i++) { char kind[16]; int m; scanf("%15s %d", kind, &m); int fee = m / 1440 * 20000 + part_fee(m % 1440); if (strcmp(kind, "disabled") == 0) { fee = fee / 5; /* 80% 할인 = 5분의 1 */ } else if (strcmp(kind, "compact") == 0) { if (m <= 1440) { fee = fee / 2; /* 하루를 넘기면 경차 할인이 없다 */ } } printf("%d\n", fee); } return 0;}
Craykonmain.cray · 39 行// 하루가 안 되는 t분의 요금부분요금(t){ もし (t <= 30) { 返す 0; } 요금 = 2000; もし (t > 60) { 요금 += 数学.切り上げ((t - 60) / 10) * 500; // /는 실수 나눗셈이라 올림으로 묶음 수를 센다 } 返す 数学.小さい方(요금, 20000);} n = コンソール.行読み().数に();차들 = [];繰り返す (i = 0; i < n; i++){ 차들.追加(コンソール.行読み().空白除去().分ける());}それぞれ (차 の中 차들){ 종류 = 차[0]; m = 차[1].数に(); 요금 = 数学.商(m, 1440) * 20000 + 부분요금(m % 1440); もし (종류 == "disabled") { 요금 = 요금 / 5; // 80% 할인. 요금은 500의 배수라 나누어떨어진다 } でなければ もし (종류 == "compact") { もし (m <= 1440) { 요금 = 요금 / 2; // 하루를 넘기면 경차 할인이 없다 } } コンソール.書く(요금);}