結果

問題 No.311 z in FizzBuzzString
ユーザー kenji_shioyakenji_shioya
提出日時 2016-05-30 23:02:37
言語 Java21
(openjdk 21)
結果
AC  
実行時間 131 ms / 1,500 ms
コード長 476 bytes
コンパイル時間 3,306 ms
コンパイル使用メモリ 74,436 KB
実行使用メモリ 57,936 KB
最終ジャッジ日時 2023-10-25 02:44:51
合計ジャッジ時間 5,518 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 129 ms
57,560 KB
testcase_01 AC 117 ms
56,264 KB
testcase_02 AC 128 ms
57,584 KB
testcase_03 AC 131 ms
57,936 KB
testcase_04 AC 128 ms
57,612 KB
testcase_05 AC 129 ms
57,520 KB
testcase_06 AC 128 ms
57,436 KB
testcase_07 AC 124 ms
57,336 KB
testcase_08 AC 128 ms
57,432 KB
testcase_09 AC 130 ms
57,628 KB
testcase_10 AC 127 ms
55,368 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;

public class Exercise37{
  public static void main (String[] args){

    Scanner sc = new Scanner(System.in);

    long num = sc.nextLong();
    long count = num / 15 * 16;
    long countNeeded = num % 15;

    for (long n = 1; n <= countNeeded; n++){
      if (n % 3 == 0 && n % 5 == 0){
        count += 4;
      }else if(n % 3 == 0){
        count += 2;
      }else if(n % 5 == 0){
        count += 2;
      }
    }
    System.out.println(count);
  }
}
0