結果

問題 No.1005 BOT対策
ユーザー tentententen
提出日時 2022-09-13 18:16:32
言語 Java21
(openjdk 21)
結果
AC  
実行時間 56 ms / 2,000 ms
コード長 1,371 bytes
コンパイル時間 2,633 ms
コンパイル使用メモリ 77,588 KB
実行使用メモリ 37,088 KB
最終ジャッジ日時 2024-05-08 02:14:57
合計ジャッジ時間 5,152 ms
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 53 ms
36,756 KB
testcase_01 AC 54 ms
36,720 KB
testcase_02 AC 53 ms
36,928 KB
testcase_03 AC 54 ms
37,088 KB
testcase_04 AC 54 ms
36,908 KB
testcase_05 AC 54 ms
36,688 KB
testcase_06 AC 55 ms
36,944 KB
testcase_07 AC 54 ms
36,760 KB
testcase_08 AC 56 ms
36,928 KB
testcase_09 AC 55 ms
36,764 KB
testcase_10 AC 53 ms
36,852 KB
testcase_11 AC 55 ms
36,792 KB
testcase_12 AC 54 ms
36,548 KB
testcase_13 AC 55 ms
36,776 KB
testcase_14 AC 55 ms
36,940 KB
testcase_15 AC 55 ms
37,040 KB
testcase_16 AC 55 ms
36,952 KB
testcase_17 AC 54 ms
36,936 KB
testcase_18 AC 55 ms
36,928 KB
testcase_19 AC 55 ms
36,876 KB
testcase_20 AC 55 ms
36,952 KB
testcase_21 AC 53 ms
36,792 KB
testcase_22 AC 55 ms
36,948 KB
testcase_23 AC 54 ms
36,932 KB
testcase_24 AC 54 ms
36,984 KB
testcase_25 AC 55 ms
36,928 KB
testcase_26 AC 54 ms
36,976 KB
testcase_27 AC 53 ms
36,892 KB
testcase_28 AC 56 ms
36,644 KB
testcase_29 AC 53 ms
37,036 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.io.*;
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner();
        String s = sc.next();
        String t = sc.next();
        if (t.length() == 1) {
            if (s.contains(t)) {
                System.out.println(-1);
            } else {
                System.out.println(0);
            }
            return;
        }
        int start = 0;
        int ans = 0;
        while ((start = s.indexOf(t, start)) >= 0) {
            ans++;
            start += t.length() - 1;
        }
        System.out.println(ans);
    }
}
    
class Scanner {
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    StringTokenizer st = new StringTokenizer("");
    StringBuilder sb = new StringBuilder();
    
    public Scanner() throws Exception {
        
    }
    
    public int nextInt() throws Exception {
        return Integer.parseInt(next());
    }
    
    public long nextLong() throws Exception {
        return Long.parseLong(next());
    }
    
    public double nextDouble() throws Exception {
        return Double.parseDouble(next());
    }
    
    public String next() throws Exception {
        while (!st.hasMoreTokens()) {
            st = new StringTokenizer(br.readLine());
        }
        return st.nextToken();
    }
    
}
0