結果

問題 No.1005 BOT対策
ユーザー ks2m
提出日時 2020-03-06 22:50:05
言語 Java
(openjdk 23)
結果
WA  
実行時間 -
コード長 581 bytes
コンパイル時間 2,183 ms
コンパイル使用メモリ 74,480 KB
実行使用メモリ 54,440 KB
最終ジャッジ日時 2024-10-14 10:49:35
合計ジャッジ時間 7,208 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 20 WA * 7
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		char[] s = sc.next().toCharArray();
		char[] t = sc.next().toCharArray();
		sc.close();

		if (t.length == 1) {
			System.out.println(-1);
			return;
		}

		int ans = 0;
		int j = 0;
		for (int i = 0; i < s.length; i++) {
			if (s[i] == t[j]) {
				if (j == t.length - 1) {
					ans++;
					j = 0;
					if (s[i] == t[j]) {
						j++;
					}
				} else {
					j++;
				}
			} else {
				j = 0;
			}
		}
		System.out.println(ans);
	}
}
0