結果

問題 No.311 z in FizzBuzzString
ユーザー bellbell
提出日時 2021-02-23 17:07:11
言語 Java19
(openjdk 21)
結果
RE  
実行時間 -
コード長 539 bytes
コンパイル時間 2,118 ms
コンパイル使用メモリ 76,432 KB
実行使用メモリ 57,944 KB
最終ジャッジ日時 2023-10-25 03:02:29
合計ジャッジ時間 4,210 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 132 ms
57,576 KB
testcase_01 AC 130 ms
57,492 KB
testcase_02 AC 130 ms
57,404 KB
testcase_03 AC 130 ms
57,540 KB
testcase_04 AC 131 ms
57,480 KB
testcase_05 AC 137 ms
57,696 KB
testcase_06 AC 137 ms
55,652 KB
testcase_07 RE -
testcase_08 RE -
testcase_09 RE -
testcase_10 RE -
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		String temp ="";
		int 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