結果

問題 No.1005 BOT対策
ユーザー htensaihtensai
提出日時 2020-03-25 09:57:18
言語 Java21
(openjdk 21)
結果
AC  
実行時間 133 ms / 2,000 ms
コード長 608 bytes
コンパイル時間 1,954 ms
コンパイル使用メモリ 71,508 KB
実行使用メモリ 56,164 KB
最終ジャッジ日時 2023-08-30 09:27:58
合計ジャッジ時間 7,079 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 122 ms
55,468 KB
testcase_01 AC 121 ms
55,868 KB
testcase_02 AC 119 ms
55,720 KB
testcase_03 AC 121 ms
55,756 KB
testcase_04 AC 117 ms
55,880 KB
testcase_05 AC 124 ms
55,796 KB
testcase_06 AC 128 ms
55,796 KB
testcase_07 AC 125 ms
55,752 KB
testcase_08 AC 131 ms
56,060 KB
testcase_09 AC 121 ms
55,856 KB
testcase_10 AC 124 ms
55,516 KB
testcase_11 AC 130 ms
56,044 KB
testcase_12 AC 132 ms
55,792 KB
testcase_13 AC 123 ms
55,812 KB
testcase_14 AC 124 ms
55,796 KB
testcase_15 AC 127 ms
55,952 KB
testcase_16 AC 128 ms
55,508 KB
testcase_17 AC 124 ms
55,816 KB
testcase_18 AC 133 ms
55,852 KB
testcase_19 AC 122 ms
54,416 KB
testcase_20 AC 125 ms
56,068 KB
testcase_21 AC 132 ms
55,916 KB
testcase_22 AC 126 ms
55,928 KB
testcase_23 AC 121 ms
55,752 KB
testcase_24 AC 123 ms
55,904 KB
testcase_25 AC 122 ms
55,944 KB
testcase_26 AC 125 ms
56,032 KB
testcase_27 AC 124 ms
56,040 KB
testcase_28 AC 125 ms
56,164 KB
testcase_29 AC 120 ms
55,992 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.contains(t)) {
            System.out.println(-1);
            return;
        }
        int start = 0;
        int count = 0;
        while (true) {
            int result = s.indexOf(t, start);
            if (result == -1) {
                break;
            }
            count++;
            start = result + t.length() - 1;
        }
        System.out.println(count);
    }
}
0