結果

問題 No.311 z in FizzBuzzString
ユーザー SagTokiSagToki
提出日時 2018-05-18 11:21:59
言語 Java21
(openjdk 21)
結果
AC  
実行時間 126 ms / 1,500 ms
コード長 960 bytes
コンパイル時間 3,226 ms
コンパイル使用メモリ 74,708 KB
実行使用メモリ 57,604 KB
最終ジャッジ日時 2023-10-25 02:55:03
合計ジャッジ時間 5,172 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 123 ms
57,564 KB
testcase_01 AC 124 ms
57,236 KB
testcase_02 AC 125 ms
57,448 KB
testcase_03 AC 124 ms
57,604 KB
testcase_04 AC 124 ms
57,372 KB
testcase_05 AC 115 ms
56,276 KB
testcase_06 AC 124 ms
57,596 KB
testcase_07 AC 123 ms
57,272 KB
testcase_08 AC 115 ms
56,272 KB
testcase_09 AC 126 ms
57,516 KB
testcase_10 AC 113 ms
56,272 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Scanner;
import java.util.InputMismatchException;

public class FizzBuzz {
    public static void main(String[] args){
        Scanner scanner = new Scanner(System.in);
        try{
            //入力される数値の定義と範囲内かのチェック
            long N = scanner.nextLong();
            if(N < 1 || N > Math.pow(10,18)){
                System.out.println("数字は1以上10の18乗以下で入力してください");
                System.exit(0);
            }
            //3の倍数と5の倍数の個数を求めてFizzとBuzzともにzが2個あるので2掛ける
            long FizzBuzzString = (N / 3 + N / 5) * 2 ;
            System.out.println(FizzBuzzString);
            
        }catch(InputMismatchException e){
            System.out.println("数字を入力してください");
        }catch(Exception E){
            System.out.println("予期せぬエラーです");
        }
    }    
}
0