結果

問題 No.311 z in FizzBuzzString
ユーザー bellbell
提出日時 2021-02-23 17:08:04
言語 Java21
(openjdk 21)
結果
TLE  
実行時間 -
コード長 542 bytes
コンパイル時間 2,193 ms
コンパイル使用メモリ 76,368 KB
実行使用メモリ 57,876 KB
最終ジャッジ日時 2023-10-25 03:02:34
合計ジャッジ時間 6,335 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 135 ms
57,632 KB
testcase_01 AC 135 ms
57,556 KB
testcase_02 AC 136 ms
57,744 KB
testcase_03 AC 137 ms
57,572 KB
testcase_04 AC 135 ms
57,844 KB
testcase_05 AC 138 ms
57,876 KB
testcase_06 AC 138 ms
57,696 KB
testcase_07 TLE -
testcase_08 -- -
testcase_09 -- -
testcase_10 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		long n = sc.nextLong();
		String temp ="";
		long count = 0;
		for (int i = 1; i <= n; i++) {
			if (i % 3 == 0 && i % 5 ==0) {
				temp += "FizzBuzz";
			} else if (i % 3 == 0) {
				temp += "Fizz";
			}else if (i % 5 == 0) {
				temp +="Buzz";
			}
		}
		for (int i = 0; i < temp.length(); i++){
			if (temp.substring(i , i+1).equals("z")){
				count++;
			}
		}
		System.out.println(count);
		sc.close();
	}
}
0