Codeforces 1347A - A+B (Trial Pr

2020-06-09  本文已影响0人  费城的二鹏

日常一道算法题。卡题了,先选旧题水水。

翻译

A + B

给你两个数字 a 和 b 输出 a + b。

输入格式

输入整数 t 表示测试用例组数。

输出格式

每一组测试用例输出 a + b 的结果。

分析

直接输出 a + b。

代码(kotlin)

// https://codeforces.com/contest/1347/problem/A

import java.io.*
import kotlin.math.max

private var br: BufferedReader? = null

private fun br(): BufferedReader? {
    if (br == null) {
        var isLocal = false
        val file = File("./file/input.txt")

        try {
            isLocal = file.exists()
        } catch (e: Exception) {

        }

        br = if (isLocal) {
            BufferedReader(BufferedReader(FileReader(file)));
        } else {
            BufferedReader(InputStreamReader(System.`in`))
        }
    }
    return br
}

private fun readLn() = br()?.readLine()!! // string line
private fun readInt() = readLn().toInt() // single int
private fun readLong() = readLn().toLong() // single long
private fun readDouble() = readLn().toDouble() // single double
private fun readStrings() = readLn().split(" ") // list of strings
private fun readInts() = readStrings().map { it.toInt() } // list of ints
private fun readLongs() = readStrings().map { it.toLong() } // list of longs
private fun readDoubles() = readStrings().map { it.toDouble() } // list of doubles
private fun readArray() = readStrings().map { it.toInt() }.toIntArray() // list of ints

fun case() {
    var (a, b) = readInts()
    println(a + b)
}

fun main() {
    var t = readInt()
    while (t-- > 0) {
        case()
    }
}

更多代码尽在 https://github.com/Tconan99/Codeforces

by 费城的二鹏 2020.06.08 长春

上一篇 下一篇

猜你喜欢

热点阅读