結果

問題 No.381 名声値を稼ごう Extra
ユーザー mamekinmamekin
提出日時 2016-07-18 18:48:44
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
TLE  
実行時間 -
コード長 1,086 bytes
コンパイル時間 1,072 ms
コンパイル使用メモリ 105,360 KB
実行使用メモリ 13,116 KB
最終ジャッジ日時 2024-04-23 16:34:19
合計ジャッジ時間 10,626 ms
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,816 KB
testcase_01 TLE -
権限があれば一括ダウンロードができます

ソースコード

diff #

#define _USE_MATH_DEFINES
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <complex>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <limits>
#include <climits>
#include <cfloat>
#include <functional>
using namespace std;

int main()
{
    string s;
    cin >> s;
    s = string(8 - (s.size() - 1) % 9, '0') + s;
    int n = s.size();

    vector<long long> v(1, 0);
    for(int i=0; i<n; i+=9){
        vector<long long> w(v.size()+1, 0);
        w[0] = stoi(s.substr(i, 9));

        for(unsigned j=0; j<v.size(); ++j){
            w[j] += v[j] * 1000000000;
            w[j+1] = w[j] >> 32;
            w[j] &= (1LL << 32) - 1;
        }
        if(w.back() == 0)
            w.pop_back();
        v.swap(w);
    }

    int ans = 0;
    for(unsigned i=0; i<v.size(); ++i){
        bitset<32> bs(v[i]);
        ans += bs.count();
    }
    cout << ans << endl;

    return 0;
}
0