結果
問題 | No.642 Two Operations No.1 |
ユーザー |
![]() |
提出日時 | 2020-02-18 21:57:25 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 2 ms / 2,000 ms |
コード長 | 478 bytes |
コンパイル時間 | 1,940 ms |
コンパイル使用メモリ | 192,200 KB |
最終ジャッジ日時 | 2025-01-09 01:05:16 |
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 15 |
ソースコード
#include <bits/stdc++.h> #define rep(i,n) for(int i=0;i<n;i++) typedef long long ll; const int MOD = ((int)1e9)+7; const int INF = (int)(1e9)+(int)(1e7); const ll INFL = (ll)(1e18)+INF; const double EPS = 1e-8; using namespace std; int main() { int N; cin >> N; int X = 1; int ans=0; while(X<N){ X<<=1; ans++; } int res=X-N; for(int i=31;i>=0;i--){ if(((1L<<i)&res)!=0)ans++; } cout << ans << endl; return 0; }