結果

問題 No.311 z in FizzBuzzString
ユーザー mos_13184925mos_13184925
提出日時 2018-07-08 17:37:53
言語 Java21
(openjdk 21)
結果
RE  
実行時間 -
コード長 430 bytes
コンパイル時間 2,016 ms
コンパイル使用メモリ 78,812 KB
実行使用メモリ 57,768 KB
最終ジャッジ日時 2023-10-25 02:55:31
合計ジャッジ時間 4,180 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 131 ms
57,508 KB
testcase_01 AC 132 ms
57,516 KB
testcase_02 AC 129 ms
57,700 KB
testcase_03 AC 129 ms
57,456 KB
testcase_04 AC 128 ms
57,600 KB
testcase_05 AC 129 ms
57,512 KB
testcase_06 AC 127 ms
57,736 KB
testcase_07 RE -
testcase_08 RE -
testcase_09 RE -
testcase_10 RE -
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int ans = 0;
        for(int i = 1; i <= n; i++) {
            if(i % 3 == 0 && i % 5 == 0) {
                ans += 4;
            } else if(i % 3 == 0 || i % 5 == 0) {
                ans += 2;
            }
        }
        System.out.println(ans);
    }
}
0