結果

問題 No.9002 FizzBuzz(テスト用)
ユーザー kenkooookenkoooo
提出日時 2015-03-14 03:28:07
言語 Java21
(openjdk 21)
結果
AC  
実行時間 50 ms / 5,000 ms
コード長 1,046 bytes
コンパイル時間 2,108 ms
コンパイル使用メモリ 73,408 KB
実行使用メモリ 49,216 KB
最終ジャッジ日時 2023-09-11 08:19:32
合計ジャッジ時間 2,757 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 43 ms
49,216 KB
testcase_01 AC 44 ms
48,828 KB
testcase_02 AC 46 ms
49,044 KB
testcase_03 AC 50 ms
48,984 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.io.IOException;

public class Main {

	public static void main(String[] args) {
		int N = nextInt();
		for (int a = 1; a <= N; a++) {
			if (a % 3 == 0 && a % 5 == 0) {
				System.out.print("FizzBuzz");
			} else if (a % 3 == 0) {
				System.out.print("Fizz");
			} else if (a % 5 == 0) {
				System.out.print("Buzz");
			} else {
				System.out.print(a);
			}
			System.out.println();

		}

	}

	static int gcd(int a, int b) {
		// b=0ならaを最大公約数として終了
		if (b == 0) {
			return a;
		} else {
			// a÷bのあまりをb、元のbをaとして2.にもどる
			return gcd(b, a % b);
		}
	}

	static int nextInt() {
		int c;
		try {
			c = System.in.read();
			while (c != '-' && (c < '0' || c > '9'))
				c = System.in.read();
			if (c == '-')
				return -nextInt();
			int res = 0;
			while (c >= '0' && c <= '9') {
				res = res * 10 + c - '0';
				c = System.in.read();
			}
			return res;
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		return -1;
	}

}
0