結果

問題 No.1450 nahco314's First Problem
コンテスト
ユーザー iiljj
提出日時 2021-03-31 15:02:48
言語 C(gnu17)
(gcc 15.2.0)
コンパイル:
gcc-15 -O2 -std=gnu17 -Wno-error=implicit-function-declaration -Wno-error=implicit-int -Wno-error=incompatible-pointer-types -Wno-error=int-conversion -DONLINE_JUDGE -o a.out _filename_ -lm
実行:
./a.out
結果
AC  
実行時間 2 ms / 2,000 ms
コード長 878 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 220 ms
コンパイル使用メモリ 39,324 KB
最終ジャッジ日時 2026-02-22 07:03:37
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 37
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

#pragma GCC optimize("Ofast")
#pragma GCC target("avx2")

// mmap
#include <sys/mman.h>
// write
#include <unistd.h>
// exit
#include <stdio.h>
#include <stdlib.h>

// clang-format off
#define RD(v) unsigned long long v=0;{int _c;while(_c=*rp++-48,_c>=0)v=v*10+_c;} //
#define RD2(v) {int _c;int sign=1;if(*rp=='-'){sign=-1;rp++;}while(_c=*rp++-48,_c>=0)v=v*10+_c;v*=sign;} //
// clang-format on

int main() {
    // void *mmap(void * addr , size_t length , int prot , int flags , int fd , off_t offset );
    char *rp = (char *)mmap(0l, 1l << 28, 1, 2, 0, 0ll);
    RD(x);

    for (unsigned long long m = 0; m < 64; ++m) {
        unsigned long long n = x ^ m;
        if (n <= 0) continue;
        int m2 = __builtin_popcountll(n);
        if (m2 == m) {
            printf("%lld\n", n);
            return 0;
        }
    }

    printf("-1\n");
    exit(0);
    return 0;
}
0