結果

問題 No.3022 縛りFizzBuzz (Easy)
ユーザー uwiuwi
提出日時 2017-03-31 22:33:07
言語 Java19
(openjdk 21)
結果
AC  
実行時間 112 ms / 2,000 ms
コード長 1,192 bytes
コンパイル時間 3,134 ms
コンパイル使用メモリ 75,112 KB
実行使用メモリ 56,424 KB
最終ジャッジ日時 2023-09-21 10:55:02
合計ジャッジ時間 4,502 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 109 ms
55,820 KB
testcase_01 AC 107 ms
55,892 KB
testcase_02 AC 112 ms
56,284 KB
testcase_03 AC 112 ms
56,424 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.io.PrintWriter;
import java.math.BigInteger;
import java.util.Scanner;

public class D {
	static Scanner in;
	static PrintWriter out;
	static String INPUT = "";
	
	static void solve()
	{
		int n = ni();
		int three = (int)Math.sqrt(BigInteger.TEN.intValue());
		int five = BigInteger.TEN.divide(BigInteger.ONE.add(BigInteger.ONE)).intValue();
		int start = BigInteger.ONE.intValue();
		while(start <= n){
			boolean isdt = BigInteger.valueOf(start).mod(BigInteger.valueOf(three)).equals(BigInteger.ZERO);
			boolean isdf = BigInteger.valueOf(start).mod(BigInteger.valueOf(five)).equals(BigInteger.ZERO);
			if(isdt && isdf){
				out.println("FizzBuzz");
			}else if(isdt){
				out.println("Fizz");
			}else if(isdf){
				out.println("Buzz");
			}else{
				out.println(start);
			}
			start++;
		}
	}
	
	public static void main(String[] args) throws Exception
	{
		in = INPUT.isEmpty() ? new Scanner(System.in) : new Scanner(INPUT);
		out = new PrintWriter(System.out);
		
		solve();
		out.flush();
	}
	
	static int ni() { return Integer.parseInt(in.next()); }
	static long nl() { return Long.parseLong(in.next()); }
	static double nd() { return Double.parseDouble(in.next()); }
}
0