結果

問題 No.1005 BOT対策
ユーザー htensaihtensai
提出日時 2020-03-25 09:55:31
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 604 bytes
コンパイル時間 3,966 ms
コンパイル使用メモリ 71,800 KB
実行使用メモリ 56,096 KB
最終ジャッジ日時 2023-08-30 09:27:50
合計ジャッジ時間 8,781 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 123 ms
55,492 KB
testcase_01 AC 126 ms
55,632 KB
testcase_02 AC 122 ms
55,592 KB
testcase_03 AC 128 ms
55,788 KB
testcase_04 AC 125 ms
55,212 KB
testcase_05 AC 123 ms
55,792 KB
testcase_06 AC 124 ms
55,800 KB
testcase_07 AC 122 ms
56,096 KB
testcase_08 AC 124 ms
55,904 KB
testcase_09 AC 123 ms
55,464 KB
testcase_10 AC 130 ms
55,688 KB
testcase_11 AC 131 ms
55,768 KB
testcase_12 WA -
testcase_13 AC 123 ms
55,656 KB
testcase_14 AC 121 ms
55,492 KB
testcase_15 AC 123 ms
55,444 KB
testcase_16 AC 126 ms
55,712 KB
testcase_17 AC 127 ms
55,960 KB
testcase_18 AC 127 ms
55,852 KB
testcase_19 AC 127 ms
55,936 KB
testcase_20 AC 125 ms
55,916 KB
testcase_21 AC 129 ms
55,292 KB
testcase_22 AC 127 ms
56,092 KB
testcase_23 AC 130 ms
55,528 KB
testcase_24 AC 132 ms
55,584 KB
testcase_25 AC 128 ms
55,544 KB
testcase_26 AC 125 ms
55,796 KB
testcase_27 AC 127 ms
55,756 KB
testcase_28 WA -
testcase_29 AC 124 ms
55,508 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();
        }
        System.out.println(count);
    }
}
0