Skip to content

L1-074 两小时学完 C 语言

Q.JPG

知乎上有个宝宝问:“两个小时内如何学完 C 语言?”当然,问的是“学完”并不是“学会”。

假设一本 C 语言教科书有 N 个字,这个宝宝每分钟能看 K 个字,看了 M 分钟。还剩多少字没有看?

输入格式:

输入在一行中给出 3 个正整数,分别是 N(不超过 400 000),教科书的总字数;K(不超过 3 000),是宝宝每分钟能看的字数;M(不超过 120),是宝宝看书的分钟数。

题目保证宝宝看完的字数不超过 N。

输出格式:

在一行中输出宝宝还没有看的字数。

输入样例:

tex
100000 1000 72
100000 1000 72

输出样例:

tex
28000
28000

Solution:

java
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
    public static void main(String[] args) throws IOException {
        BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
        String[] input = in.readLine().split(" ");
        int N = Integer.parseInt(input[0]);
        int K = Integer.parseInt(input[1]);
        int M = Integer.parseInt(input[2]);
        System.out.println(N - K * M);
    }
}
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
    public static void main(String[] args) throws IOException {
        BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
        String[] input = in.readLine().split(" ");
        int N = Integer.parseInt(input[0]);
        int K = Integer.parseInt(input[1]);
        int M = Integer.parseInt(input[2]);
        System.out.println(N - K * M);
    }
}

Released under the MIT License.