結果

問題 No.1869 Doubling?
ユーザー boatmuscles
提出日時 2022-03-11 22:43:16
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 314 bytes
コンパイル時間 287 ms
コンパイル使用メモリ 27,904 KB
最終ジャッジ日時 2025-01-28 08:53:44
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 42 WA * 1
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:5:10: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
    5 |     scanf("%u %u", &N, &M);
      |     ~~~~~^~~~~~~~~~~~~~~~~

ソースコード

diff #

#include<cstdio>

int main(){
    unsigned N, M;
    scanf("%u %u", &N, &M);
    unsigned answer = 0;
    if(N < 30 && M > 1U<<(N-1)){
        printf("%u\n", (1U<<N) - 1);
        return 0;
    }
    while(N && M > 1){
        answer += M;
        M = (M+1)>>1;
        N--;
    }
    printf("%u\n", answer + N);
}
0