結果

問題 No.207 世界のなんとか
ユーザー tentententen
提出日時 2020-11-11 08:24:27
言語 Java21
(openjdk 21)
結果
AC  
実行時間 130 ms / 5,000 ms
コード長 691 bytes
コンパイル時間 2,059 ms
コンパイル使用メモリ 71,940 KB
実行使用メモリ 56,208 KB
最終ジャッジ日時 2023-09-30 00:21:26
合計ジャッジ時間 5,868 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 126 ms
55,896 KB
testcase_01 AC 127 ms
55,712 KB
testcase_02 AC 127 ms
56,020 KB
testcase_03 AC 126 ms
55,684 KB
testcase_04 AC 128 ms
55,888 KB
testcase_05 AC 129 ms
56,208 KB
testcase_06 AC 130 ms
55,820 KB
testcase_07 AC 126 ms
55,412 KB
testcase_08 AC 126 ms
55,664 KB
testcase_09 AC 126 ms
56,052 KB
testcase_10 AC 125 ms
53,704 KB
testcase_11 AC 128 ms
55,844 KB
testcase_12 AC 127 ms
55,656 KB
testcase_13 AC 129 ms
55,812 KB
testcase_14 AC 128 ms
56,092 KB
testcase_15 AC 129 ms
55,816 KB
testcase_16 AC 124 ms
55,988 KB
testcase_17 AC 123 ms
55,996 KB
testcase_18 AC 128 ms
55,664 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        StringBuilder sb = new StringBuilder();
        for (int i = a; i <= b; i++) {
            if (isMatch(i)) {
                sb.append(i).append("\n");
            }
        }
        System.out.print(sb);
    }
    
    static boolean isMatch(int x) {
        int sum = 0;
        while (x > 0) {
            int mod = x % 10;
            if (mod == 3) {
                return true;
            }
            sum += mod;
            x /= 10;
        }
        return (sum % 3 == 0);
    }
}
0