結果

問題 No.311 z in FizzBuzzString
ユーザー bell
提出日時 2021-02-23 17:07:11
言語 Java
(openjdk 23)
結果
RE  
実行時間 -
コード長 539 bytes
コンパイル時間 2,324 ms
コンパイル使用メモリ 76,244 KB
実行使用メモリ 56,176 KB
最終ジャッジ日時 2024-09-24 22:35:37
合計ジャッジ時間 4,200 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 7 RE * 4
権限があれば一括ダウンロードができます

ソースコード

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