結果

問題 No.1742 Binary Indexed Train
ユーザー t98slider
提出日時 2021-11-13 09:16:21
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 277 ms / 3,000 ms
コード長 359 bytes
コンパイル時間 1,684 ms
コンパイル使用メモリ 166,140 KB
実行使用メモリ 6,824 KB
最終ジャッジ日時 2024-11-26 21:43:52
合計ジャッジ時間 9,721 ms
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 32
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function 'int main()':
main.cpp:16:69: warning: 'msb' may be used uninitialized [-Wmaybe-uninitialized]
   16 |         cout<<__builtin_popcountll(msb-s%msb)+__builtin_popcountll(t%msb)<<'\n';
      |                                                                    ~^~~~
main.cpp:7:14: note: 'msb' was declared here
    7 |     long s,t,msb;
      |              ^~~

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;

int main(){
    int n,q;
    cin>>n>>q;
    long s,t,msb;
    while(q--){
        cin>>s>>t;
        for(int i=n;i>=0;i--){
            if((s^t)>>i){
                msb=1LL<<i;
                break;
            }
        }
        cout<<__builtin_popcountll(msb-s%msb)+__builtin_popcountll(t%msb)<<'\n';
    }
}
0