結果
| 問題 | No.47 ポケットを叩くとビスケットが2倍 |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2019-08-07 21:52:44 |
| 言語 | C++14 (gcc 15.2.0 + boost 1.89.0) |
| 結果 |
CE
(最新)
AC
(最初)
|
| 実行時間 | - |
| コード長 | 1,178 bytes |
| 記録 | |
| コンパイル時間 | 596 ms |
| コンパイル使用メモリ | 86,264 KB |
| 最終ジャッジ日時 | 2026-04-02 12:07:08 |
| 合計ジャッジ時間 | 1,050 ms |
|
ジャッジサーバーID (参考情報) |
judge5_1 / judge2_1 |
(要ログイン)
コンパイルエラー時のメッセージ・ソースコードは、提出者また管理者しか表示できないようにしております。(リジャッジ後のコンパイルエラーは公開されます)
ただし、clay言語の場合は開発者のデバッグのため、公開されます。
ただし、clay言語の場合は開発者のデバッグのため、公開されます。
コンパイルメッセージ
main.cpp:40:12: error: 'uint64_t' was not declared in this scope
40 | int popcnt(uint64_t n)
| ^~~~~~~~
main.cpp:10:1: note: 'uint64_t' is defined in header '<cstdint>'; this is probably fixable by adding '#include <cstdint>'
9 | #include <algorithm>
+++ |+#include <cstdint>
10 |
main.cpp:45:11: error: 'uint64_t' was not declared in this scope
45 | int tzcnt(uint64_t n)
| ^~~~~~~~
main.cpp:45:11: note: 'uint64_t' is defined in header '<cstdint>'; this is probably fixable by adding '#include <cstdint>'
main.cpp:50:11: error: 'uint64_t' was not declared in this scope
50 | int lzcnt(uint64_t n)
| ^~~~~~~~
main.cpp:50:11: note: 'uint64_t' is defined in header '<cstdint>'; this is probably fixable by adding '#include <cstdint>'
main.cpp: In function 'int main()':
main.cpp:61:13: error: 'popcnt' cannot be used as a function
61 | if (popcnt(n) == 1) ans--;
| ~~~~~~^~~
ソースコード
#include <iostream>
#include <vector>
#include <utility>
#include <set>
#include <list>
#include <cassert>
#include <queue>
#include <cmath>
#include <algorithm>
using namespace std;
using ll = long long int;
#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define YES(n) std::cout << ((n) ? "YES" : "NO" ) << "\n";
#define Yes(n) std::cout << ((n) ? "Yes" : "No" ) << "\n";
#define ALL_INCLUDED_ENVIRONMENT
template <class T, class Alloc, template <class, class> class C> std::ostream& operator<<(std::ostream& o, const C<T, Alloc>& v) {
o << "{";
bool init = 1;
for (auto e : v) {
if (init) { init = 0; }
else { o << ", "; }
o << e;
}
o << "}";
return o;
}
int int_width (ll x) {
int ans = 0;
while(x > 0) {
x = x >> 1;
ans++;
}
return ans;
}
int popcnt(uint64_t n)
{
return __builtin_popcountll(n);
}
int tzcnt(uint64_t n)
{
return n == 0 ? 64 : __builtin_ctzll(n);
}
int lzcnt(uint64_t n)
{
return n == 0 ? 64 : __builtin_clzll(n);
}
int main() {
// cin.tie(0);
// ios::sync_with_stdio(false);
ll n;
cin >> n;
ll ans = int_width(n);
if (popcnt(n) == 1) ans--;
cout << ans << "\n";
return 0;
}