結果

問題 No.637 X: Yet Another FizzBuzz Problem
ユーザー GodNegoto
提出日時 2019-11-28 10:18:01
言語 Java
(openjdk 23)
結果
AC  
実行時間 146 ms / 1,000 ms
コード長 728 bytes
コンパイル時間 4,173 ms
コンパイル使用メモリ 77,796 KB
実行使用メモリ 41,560 KB
最終ジャッジ日時 2024-11-17 12:30:34
合計ジャッジ時間 10,400 ms
ジャッジサーバーID
(参考情報)
judge1 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 30
権限があれば一括ダウンロードができます

ソースコード

diff #

package algo;

import java.util.*;

public class sample7 {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a1 = sc.nextInt();
		int a2 = sc.nextInt();
		int a3 = sc.nextInt();
		int a4 = sc.nextInt();
		int a5 = sc.nextInt();
		List<Integer> list = new ArrayList<Integer>();
		list.add(a1);
		list.add(a2);
		list.add(a3);
		list.add(a4);
		list.add(a5);
		int sum = 0;
		for(int i = 0; i < list.size(); i++) {
			if(list.get(i) % 3 == 0 && list.get(i) % 5 == 0) {
				sum += 8;
			}
			else if (list.get(i) % 5 == 0) {
				sum += 4;
			}
			else if (list.get(i) % 3 == 0) {
				sum += 4;
			}
			else {
				sum += list.get(i).toString().length();
			}
		}
		System.out.println(sum);
	}
}
0