結果

問題 No.1005 BOT対策
ユーザー tentententen
提出日時 2020-08-24 17:33:43
言語 Java21
(openjdk 21)
結果
AC  
実行時間 124 ms / 2,000 ms
コード長 510 bytes
コンパイル時間 2,113 ms
コンパイル使用メモリ 74,120 KB
実行使用メモリ 41,576 KB
最終ジャッジ日時 2024-04-24 03:38:35
合計ジャッジ時間 6,198 ms
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 106 ms
41,128 KB
testcase_01 AC 107 ms
40,100 KB
testcase_02 AC 114 ms
41,260 KB
testcase_03 AC 97 ms
39,828 KB
testcase_04 AC 105 ms
41,092 KB
testcase_05 AC 104 ms
41,348 KB
testcase_06 AC 93 ms
39,832 KB
testcase_07 AC 107 ms
41,128 KB
testcase_08 AC 112 ms
41,180 KB
testcase_09 AC 114 ms
41,228 KB
testcase_10 AC 107 ms
41,220 KB
testcase_11 AC 100 ms
40,312 KB
testcase_12 AC 92 ms
39,544 KB
testcase_13 AC 109 ms
41,120 KB
testcase_14 AC 111 ms
41,364 KB
testcase_15 AC 114 ms
41,380 KB
testcase_16 AC 117 ms
41,352 KB
testcase_17 AC 99 ms
40,268 KB
testcase_18 AC 114 ms
41,560 KB
testcase_19 AC 124 ms
41,200 KB
testcase_20 AC 118 ms
41,324 KB
testcase_21 AC 115 ms
41,100 KB
testcase_22 AC 111 ms
41,072 KB
testcase_23 AC 108 ms
41,140 KB
testcase_24 AC 108 ms
39,932 KB
testcase_25 AC 111 ms
41,216 KB
testcase_26 AC 100 ms
40,472 KB
testcase_27 AC 101 ms
40,540 KB
testcase_28 AC 109 ms
41,576 KB
testcase_29 AC 109 ms
41,260 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        String t = sc.next();
        if (t.length() == 1 && s.indexOf(t) >= 0) {
            System.out.println(-1);
            return;
        }
        int idx = 0;
        int count = 0;
        while ((idx = s.indexOf(t, idx)) >= 0) {
            count++;
            idx += t.length() - 1;
        }
        System.out.println(count);
    }
}
0