結果
問題 | No.589 Counting Even |
ユーザー |
|
提出日時 | 2017-11-03 22:50:05 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 2 ms / 2,000 ms |
コード長 | 547 bytes |
コンパイル時間 | 630 ms |
コンパイル使用メモリ | 69,632 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2024-11-22 16:12:19 |
合計ジャッジ時間 | 1,604 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 29 |
ソースコード
#include <iostream>#include <algorithm>#include <vector>#include <string>using namespace std;int main() {long long n;cin >> n;static long long dp[61][2][2];dp[0][0][0] = 1;for (int i = 0; i < 60; i++) {for (int j = 0; j < 2; j++) {for (int k = 0; k < 2; k++) {int x = n >> 59 - i & 1;int d = j ? 1 : x;for (int l = 0; l <= d; l++) {dp[i + 1][j || l < d][k || (x == 0 && l == 1)] += dp[i][j][k];}}}}cout << dp[60][0][1] + dp[60][1][1] << endl;}