結果
| 問題 | No.637 X: Yet Another FizzBuzz Problem | 
| コンテスト | |
| ユーザー |  kichirb3 | 
| 提出日時 | 2018-02-26 00:13:43 | 
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) | 
| 結果 | 
                                AC
                                 
                             | 
| 実行時間 | 2 ms / 1,000 ms | 
| コード長 | 1,256 bytes | 
| コンパイル時間 | 4,536 ms | 
| コンパイル使用メモリ | 234,044 KB | 
| 実行使用メモリ | 5,376 KB | 
| 最終ジャッジ日時 | 2024-06-28 18:59:11 | 
| 合計ジャッジ時間 | 5,354 ms | 
| ジャッジサーバーID (参考情報) | judge5 / judge2 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 2 | 
| other | AC * 30 | 
ソースコード
// 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;
}
            
            
            
        