結果
| 問題 |
No.1742 Binary Indexed Train
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2021-11-13 09:10:03 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 252 ms / 3,000 ms |
| コード長 | 365 bytes |
| コンパイル時間 | 1,646 ms |
| コンパイル使用メモリ | 165,456 KB |
| 実行使用メモリ | 5,248 KB |
| 最終ジャッジ日時 | 2024-11-26 21:27:24 |
| 合計ジャッジ時間 | 8,924 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| 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;
| ^~~
ソースコード
#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>>i)!=(t>>i)){
msb=1LL<<i;
break;
}
}
cout<<__builtin_popcountll(msb-s%msb)+__builtin_popcountll(t%msb)<<'\n';
}
}