結果

問題 No.9002 FizzBuzz(テスト用)
ユーザー taketake
提出日時 2016-07-10 14:02:58
言語 Java21
(openjdk 21)
結果
AC  
実行時間 116 ms / 5,000 ms
コード長 774 bytes
コンパイル時間 2,646 ms
コンパイル使用メモリ 74,104 KB
実行使用メモリ 41,200 KB
最終ジャッジ日時 2024-04-21 11:45:51
合計ジャッジ時間 3,009 ms
ジャッジサーバーID
(参考情報)
judge3 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 103 ms
40,192 KB
testcase_01 AC 113 ms
41,168 KB
testcase_02 AC 116 ms
41,200 KB
testcase_03 AC 114 ms
39,808 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

/* package whatever; // don't place package name! */

import java.util.*;
import java.lang.*;
import java.io.*;

/* Name of the class has to be "Main" only if the class is public. */
class Ideone
{
	
	public static void main (String[] args) throws java.lang.Exception
	{

	        Scanner sc = new Scanner(System.in);

	        // int 読み込む
	        int a = sc.nextInt();

		for (int i = 0; i < a; i++){
		  	// 書き出す。
	        	System.out.println(calc(i + 1));

		}
		
	}

	public static String calc(int a)
	{
		String ans = "";


		if (a % 3 == 0) {
			ans="Fizz";
		}

		if (a % 5 == 0) {
			ans="Buzz";
		}
			
		if ((a % 5 == 0) && (a % 3 == 0)) {
			ans="FizzBuzz";
		}
		
		if (ans == "") {
		
			ans= String.valueOf(a);
		}
		
		return ans;
	}

	
	
}
0