結果
| 問題 | 
                            No.642 Two Operations No.1
                             | 
                    
| コンテスト | |
| ユーザー | 
                             e869120
                         | 
                    
| 提出日時 | 2018-02-02 21:21:34 | 
| 言語 | C++14  (gcc 13.3.0 + boost 1.87.0)  | 
                    
| 結果 | 
                             
                                AC
                                 
                             
                            
                         | 
                    
| 実行時間 | 2 ms / 2,000 ms | 
| コード長 | 371 bytes | 
| コンパイル時間 | 962 ms | 
| コンパイル使用メモリ | 82,484 KB | 
| 実行使用メモリ | 6,820 KB | 
| 最終ジャッジ日時 | 2024-12-31 07:00:10 | 
| 合計ジャッジ時間 | 1,435 ms | 
| 
                            ジャッジサーバーID (参考情報)  | 
                        judge2 / judge5 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| other | AC * 15 | 
ソースコード
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <queue>
#include <functional>
#include <map>
using namespace std;
int n, p = 1, cnt;
int main() {
	cin >> n;
	while (p < n) { p *= 2; cnt++; }
	int s = p - n;
	for (int i = 0; i < 30; i++) {
		if ((s / (1 << i)) % 2 == 1) cnt++;
	}
	cout << cnt << endl;
	return 0;
}
            
            
            
        
            
e869120