結果
問題 |
No.381 名声値を稼ごう Extra
|
ユーザー |
![]() |
提出日時 | 2016-06-18 20:56:22 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 4,837 ms / 8,000 ms |
コード長 | 1,474 bytes |
コンパイル時間 | 616 ms |
コンパイル使用メモリ | 73,812 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2024-11-22 11:44:42 |
合計ジャッジ時間 | 5,844 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 2 |
ソースコード
#include <cstdio> #include <cassert> #include <cmath> #include <cstring> #include <algorithm> #include <iostream> #include <vector> #include <map> #include <set> #include <functional> #include <tuple> #define _fetch(_1, _2, _3, _4, name, ...) name #define rep2(i, n) rep3(i, 0, n) #define rep3(i, a, b) rep4(i, a, b, 1) #define rep4(i, a, b, c) for (int i = int(a); i < int(b); i += int(c)) #define rep(...) _fetch(__VA_ARGS__, rep4, rep3, rep2, _)(__VA_ARGS__) using namespace std; using i64 = long long; using u8 = unsigned char; using u32 = unsigned; using u64 = unsigned long long; using f80 = long double; void solve() { static char S[1000010]; static u64 rems[60000]; const u64 mask = (u64(1) << 18) - 1; const u64 five18 = u64(1e18) >> 18; while (~scanf("%s", S)) { int len = strlen(S); int q = len / 18, r = len % 18; rep(i, q) { u64 n = 0; rep(j, 18) n = n * 10 + S[len - 18 + j] - '0'; rems[i] = n; len -= 18; } if (r) { u64 n = 0; rep(j, r) n = n * 10 + S[len - r + j] - '0'; rems[q++] = n; len -= r; } int ans = 0; while (q) { ans += __builtin_popcount(rems[0] & mask); rep(i, q) rems[i] = (rems[i] >> 18) + (rems[i + 1] & mask) * five18; if (rems[q - 1] == 0) --q; } printf("%d\n", ans); } } int main() { clock_t beg = clock(); solve(); clock_t end = clock(); fprintf(stderr, "%.3f sec\n", double(end - beg) / CLOCKS_PER_SEC); return 0; }