結果

問題 No.637 X: Yet Another FizzBuzz Problem
ユーザー kichirb3kichirb3
提出日時 2018-02-26 00:13:43
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 2 ms / 1,000 ms
コード長 1,256 bytes
コンパイル時間 5,621 ms
コンパイル使用メモリ 230,664 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-09-11 04:31:53
合計ジャッジ時間 6,951 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 1 ms
4,376 KB
testcase_03 AC 2 ms
4,376 KB
testcase_04 AC 2 ms
4,380 KB
testcase_05 AC 2 ms
4,376 KB
testcase_06 AC 2 ms
4,380 KB
testcase_07 AC 2 ms
4,376 KB
testcase_08 AC 2 ms
4,380 KB
testcase_09 AC 1 ms
4,380 KB
testcase_10 AC 1 ms
4,376 KB
testcase_11 AC 2 ms
4,380 KB
testcase_12 AC 1 ms
4,376 KB
testcase_13 AC 1 ms
4,380 KB
testcase_14 AC 1 ms
4,380 KB
testcase_15 AC 2 ms
4,380 KB
testcase_16 AC 2 ms
4,380 KB
testcase_17 AC 1 ms
4,376 KB
testcase_18 AC 2 ms
4,376 KB
testcase_19 AC 1 ms
4,380 KB
testcase_20 AC 2 ms
4,380 KB
testcase_21 AC 2 ms
4,380 KB
testcase_22 AC 2 ms
4,380 KB
testcase_23 AC 2 ms
4,380 KB
testcase_24 AC 2 ms
4,376 KB
testcase_25 AC 2 ms
4,376 KB
testcase_26 AC 2 ms
4,380 KB
testcase_27 AC 2 ms
4,380 KB
testcase_28 AC 2 ms
4,380 KB
testcase_29 AC 2 ms
4,380 KB
testcase_30 AC 2 ms
4,380 KB
testcase_31 AC 2 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

// No.637 X: Yet Another FizzBuzz Problem
// https://yukicoder.me/problems/no/637
//
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <regex>
#include <utility>
#include <unordered_map>
#include <map>
#include <set>
#include <regex>
#include <iomanip>
#include <sstream>
#include <array>
using namespace std;

vector<string> split_input();
int fizzbuzz_length(string s);


int main() {
    vector<string> res = split_input();

    int count = 0;
    for (auto r: res) {
        count += fizzbuzz_length(r);
    }
    cout << count << endl;
}


int fizzbuzz_length(string s) {
    int n = stoi(s);
    if (n % 15 == 0)
        return 8;
    if (n % 3 == 0 || n % 5 == 0)
        return 4;
    return s.size();
}


vector<string> split_input()
{
    // 1行で入力されたカンマまたは空白文字区切りのデータを分割しその結果を返す。
    vector<string> res;
    string input_txt;
    getline(cin, input_txt);
    regex rx(R"(,|\s)");
    sregex_token_iterator it(input_txt.begin(), input_txt.end(), rx, -1);
    sregex_token_iterator end;
    while (it != end) {
        if (*it != "")
            res.push_back(*it++);
        else
            it++;
    }
    return res;
}
0