結果

問題 No.1005 BOT対策
ユーザー joybeeee
提出日時 2020-05-14 15:44:36
言語 Java
(openjdk 23)
結果
WA  
実行時間 -
コード長 673 bytes
コンパイル時間 2,275 ms
コンパイル使用メモリ 79,192 KB
実行使用メモリ 41,376 KB
最終ジャッジ日時 2024-09-15 08:03:33
合計ジャッジ時間 7,234 ms
ジャッジサーバーID
(参考情報)
judge2 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 25 WA * 2
権限があれば一括ダウンロードができます

ソースコード

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();
      
      int lenT = t.length();
      if(lenT == 1) {
          for(char c : s.toCharArray())
            if(c == t.charAt(0)) {
                System.out.println(-1);
                return;
            }
          System.out.println(0);
          return;
      }
      int cnt = 0;
      for(int i = 0; i < s.length() - lenT + 1; i++) {
        if(s.substring(i, i + lenT).equals(t)) {
          cnt++;
          i += lenT - 1;
        }
      }
      System.out.println(cnt);
  }
}
0