結果
問題 | No.381 名声値を稼ごう Extra |
ユーザー | anta |
提出日時 | 2016-06-18 00:35:16 |
言語 | C++14 (gcc 12.3.0 + boost 1.83.0) |
結果 |
AC
|
実行時間 | 50 ms / 8,000 ms |
コード長 | 1,954 bytes |
コンパイル時間 | 1,935 ms |
コンパイル使用メモリ | 163,880 KB |
実行使用メモリ | 7,708 KB |
最終ジャッジ日時 | 2023-08-14 14:02:28 |
合計ジャッジ時間 | 2,016 ms |
ジャッジサーバーID (参考情報) |
judge12 / judge14 |
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 2 ms
4,380 KB |
testcase_01 | AC | 50 ms
7,708 KB |
ソースコード
#include "bits/stdc++.h" #include <gmp.h> using namespace std; #if defined(_WIN32) extern "C" { void* __stdcall LoadLibraryA(const char *name); void* __stdcall GetProcAddress(void *handle, const char *name); } struct DynamicLibrary { DynamicLibrary(const char *name) { _handle = LoadLibraryA(name); } void *get(const char *name) const { void *p = GetProcAddress(_handle, name); if(!p) cerr << "can't find: " << name << endl, abort(); return p; } void *_handle; } gmp("mpir.dll"); #else extern "C" { void* __libc_dlopen_mode(const char *x, int y); void* __libc_dlsym(void *x, const char *y); } struct DynamicLibrary { DynamicLibrary(const char *name) { _handle = __libc_dlopen_mode(name, 2); } void *get(const char *name) const { void *p = __libc_dlsym(_handle, name); if(!p) cerr << "can't find: " << name << endl, abort(); return p; } void *_handle; } gmp("/usr/lib64/libgmp.so.10"); //yukicoder #endif #define EXPAND_MACRO_TO_STR_2(a) #a #define EXPAND_MACRO_TO_STR(a) EXPAND_MACRO_TO_STR_2(a) #define D(name) const auto my_##name = (decltype(::name)*)gmp.get(EXPAND_MACRO_TO_STR(name)) D(mpz_init_set_str); D(mpz_popcount); #define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i)) #define rer(i,l,u) for(int (i)=(int)(l);(i)<=(int)(u);++(i)) #define reu(i,l,u) for(int (i)=(int)(l);(i)<(int)(u);++(i)) static const int INF = 0x3f3f3f3f; static const long long INFL = 0x3f3f3f3f3f3f3f3fLL; typedef vector<int> vi; typedef pair<int, int> pii; typedef vector<pair<int, int> > vpii; typedef long long ll; template<typename T, typename U> static void amin(T &x, U y) { if(y < x) x = y; } template<typename T, typename U> static void amax(T &x, U y) { if(x < y) x = y; } int main() { // \sum_n (2^(n+1)-1) N[n] //= 2 N - popcnt(N) char buf[1000002]; int n = fread(buf, 1, 1000001, stdin); while(buf[n - 1] < '0') buf[-- n] = 0; mpz_t z; my_mpz_init_set_str(z, buf, 10); int ans = (int)my_mpz_popcount(z); printf("%d\n", ans); return 0; }