結果

問題 No.1663 Maximum Remainder
ユーザー JetmanJetman
提出日時 2021-09-03 21:58:30
言語 Java21
(openjdk 21)
結果
AC  
実行時間 73 ms / 2,000 ms
コード長 2,054 bytes
コンパイル時間 2,915 ms
コンパイル使用メモリ 77,552 KB
実行使用メモリ 51,192 KB
最終ジャッジ日時 2024-05-09 03:47:22
合計ジャッジ時間 4,075 ms
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 72 ms
51,152 KB
testcase_01 AC 73 ms
51,192 KB
testcase_02 AC 52 ms
50,024 KB
testcase_03 AC 53 ms
50,400 KB
testcase_04 AC 53 ms
50,136 KB
testcase_05 AC 54 ms
50,340 KB
testcase_06 AC 54 ms
50,136 KB
testcase_07 AC 57 ms
49,992 KB
testcase_08 AC 52 ms
50,516 KB
testcase_09 AC 53 ms
50,396 KB
testcase_10 AC 52 ms
50,516 KB
testcase_11 AC 53 ms
50,488 KB
testcase_12 AC 53 ms
50,268 KB
testcase_13 AC 54 ms
50,416 KB
testcase_14 AC 53 ms
50,584 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        FastReader in = new FastReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        No1663MaximumRemainder solver = new No1663MaximumRemainder();
        solver.solve(1, in, out);
        out.close();
    }

    static class No1663MaximumRemainder {
        public void solve(int testNumber, FastReader in, PrintWriter out) {
            int a = in.nextInt();
            int b = in.nextInt();
            int c = in.nextInt();
            int d = in.nextInt();

            int m = in.nextInt();
            int ans = 0;
            for (int i = a; i <= b; i++) {
                for (int j = c; j <= d; j++) {
                    ans = Math.max(ans, (i + j) % m);
                }
            }
            out.println(ans);
        }

    }

    static class FastReader {
        BufferedReader br;
        StringTokenizer st = new StringTokenizer("");

        public FastReader() {
            br = new BufferedReader(new InputStreamReader(System.in));
        }

        public FastReader(InputStream in) {
            br = new BufferedReader(new InputStreamReader(in));
        }

        public String next() {
            while (st == null || (!st.hasMoreElements())) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }

            }
            return st.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

    }
}

0