結果

問題 No.207 世界のなんとか
ユーザー SaYaSaYa
提出日時 2015-11-07 17:38:39
言語 Java21
(openjdk 21)
結果
AC  
実行時間 139 ms / 5,000 ms
コード長 908 bytes
コンパイル時間 2,253 ms
コンパイル使用メモリ 75,912 KB
実行使用メモリ 41,716 KB
最終ジャッジ日時 2024-04-17 16:30:49
合計ジャッジ時間 5,601 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 132 ms
41,304 KB
testcase_01 AC 130 ms
41,680 KB
testcase_02 AC 139 ms
41,464 KB
testcase_03 AC 135 ms
41,172 KB
testcase_04 AC 133 ms
41,480 KB
testcase_05 AC 135 ms
41,164 KB
testcase_06 AC 131 ms
41,488 KB
testcase_07 AC 131 ms
41,716 KB
testcase_08 AC 130 ms
41,400 KB
testcase_09 AC 135 ms
41,252 KB
testcase_10 AC 135 ms
41,472 KB
testcase_11 AC 136 ms
41,164 KB
testcase_12 AC 134 ms
41,580 KB
testcase_13 AC 136 ms
41,516 KB
testcase_14 AC 134 ms
41,048 KB
testcase_15 AC 131 ms
41,200 KB
testcase_16 AC 129 ms
41,356 KB
testcase_17 AC 129 ms
41,420 KB
testcase_18 AC 125 ms
40,980 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int a = Integer.parseInt(scanner.next());
        int b = Integer.parseInt(scanner.next());

        for (int i = a; i <= b; i++) {
            boolean isOutputNum = (isThreeMultiple(i)) || (isThreeContains(i));
            if (isOutputNum) {
                System.out.println(i);
            }
        }
    }

    private static boolean isThreeMultiple(int num) {
        return (num % 3 == 0);
    }

    private static boolean isThreeContains(int num) {
        String numText = Integer.toString(num);
        for (int i = 0; i < numText.length(); i++) {
            String subTextNum = numText.substring(i, i + 1);
            if (Integer.parseInt(subTextNum) == 3) {
                return true;
            }
        }
        return false;
    }
}
0