結果

問題 No.207 世界のなんとか
ユーザー reo3313reo3313
提出日時 2015-09-24 13:05:07
言語 Java21
(openjdk 21)
結果
AC  
実行時間 171 ms / 5,000 ms
コード長 985 bytes
コンパイル時間 3,620 ms
コンパイル使用メモリ 76,712 KB
実行使用メモリ 42,336 KB
最終ジャッジ日時 2024-04-17 16:26:55
合計ジャッジ時間 7,472 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 153 ms
41,520 KB
testcase_01 AC 163 ms
41,856 KB
testcase_02 AC 158 ms
41,412 KB
testcase_03 AC 155 ms
41,704 KB
testcase_04 AC 138 ms
40,580 KB
testcase_05 AC 159 ms
41,816 KB
testcase_06 AC 152 ms
41,244 KB
testcase_07 AC 154 ms
41,852 KB
testcase_08 AC 153 ms
41,772 KB
testcase_09 AC 161 ms
41,404 KB
testcase_10 AC 171 ms
41,240 KB
testcase_11 AC 162 ms
41,728 KB
testcase_12 AC 161 ms
41,576 KB
testcase_13 AC 161 ms
41,980 KB
testcase_14 AC 163 ms
42,032 KB
testcase_15 AC 164 ms
42,336 KB
testcase_16 AC 137 ms
40,668 KB
testcase_17 AC 151 ms
41,252 KB
testcase_18 AC 131 ms
41,076 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

package test1;
import java.util.Scanner;
import java.util.regex.Pattern;
import java.util.regex.Matcher;

public class test1_class {
    public static void main(String[] args) {
        // 標準入力から読み込む際に、Scannerオブジェクトを使う。
        Scanner sc = new Scanner(System.in);

        int a = sc.nextInt();
        int b = sc.nextInt();
        int i;
        int amari;
        
        for(i=a; i<=b; i++){

        	int flag = 0;
        	
        	//3の倍数
        	amari = i%3;
            if(amari==0){
            	flag = 1;
            }
        	
            //3が付く
            String str = String.valueOf(i);            
            //判定するパターンを生成
            Pattern p = Pattern.compile("3");
            Matcher m = p.matcher(str);
            if(m.find()){
            	flag = 1;
            }
            
            if(flag == 1){
            	System.out.print(i + "\n");
            }
        }
    }
}
0