結果

問題 No.589 Counting Even
コンテスト
ユーザー ats5515
提出日時 2017-11-03 22:57:20
言語 C++11
(gcc 15.3.0 + boost 1.92.0)
コンパイル:
g++-15 -O2 -lm -std=gnu++11 -Wuninitialized -DONLINE_JUDGE -o a.out _filename_
実行:
./a.out
結果
AC  
実行時間 1 ms / 2,000 ms
+ 316µs
コード長 552 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 390 ms
コンパイル使用メモリ 102,940 KB
実行使用メモリ 9,912 KB
最終ジャッジ日時 2026-09-28 05:59:10
合計ジャッジ時間 2,129 ms
ジャッジサーバーID
(参考情報)
judge1_0 / judge4_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 29
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function 'long long int f(long long int)':
main.cpp:23:1: warning: control reaches end of non-void function [-Wreturn-type]
   23 | }
      | ^

ソースコード

diff #
raw source code

#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <string>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <stdio.h>
using namespace std;
#define int long long
int MOD = 1000000007;
int f(int a) {
	if (a == 0) {
		return 1;
	}
	for (int i = 0; i < 62; i++) {
		if (a >= ((int)1 << i) && a < ((int)1 << (i + 1))) {
			return f(a - ((int)1 << i)) * 2;
		}
	}
}
signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int N;
	cin >> N;
	//N = (int)1 << 59;
	cout << N + 1 - f(N) << endl;
}
0