結果

問題 No.637 X: Yet Another FizzBuzz Problem
ユーザー neko_the_shadow
提出日時 2018-03-17 23:41:37
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 3 ms / 1,000 ms
コード長 335 bytes
コンパイル時間 636 ms
コンパイル使用メモリ 71,268 KB
最終ジャッジ日時 2025-01-05 09:18:20
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 30
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<iostream>
#include<vector>
#include<string>

using namespace std;

int fizzbuzz(int x) {
	if (x % 15 == 0) return 8; // FizzBuzz
	if (x % 3 == 0 || x % 5 == 0) return 4;  // Fizz or Buzz
	return to_string(x).size();
}

int main() {
	int a, sum = 0;
	while (cin >> a) sum += fizzbuzz(a);
	cout << sum << endl;
    return 0;
}

0