結果
| 問題 |
No.1742 Binary Indexed Train
|
| コンテスト | |
| ユーザー |
se1ka2
|
| 提出日時 | 2021-11-12 21:54:53 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 341 ms / 3,000 ms |
| コード長 | 552 bytes |
| コンパイル時間 | 682 ms |
| コンパイル使用メモリ | 64,128 KB |
| 実行使用メモリ | 5,248 KB |
| 最終ジャッジ日時 | 2024-11-25 18:14:31 |
| 合計ジャッジ時間 | 8,208 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 32 |
ソースコード
#include <iostream>
using namespace std;
typedef long long ll;
int main()
{
int n, q;
cin >> n >> q;
while(q--){
ll s, t;
cin >> s >> t;
int ans = 0;
for(int i = 0; i <= 60; i++){
if(((s >> i) & 1) && s + (1ll << i) <= t){
s += (1ll << i);
ans++;
}
}
for(int i = 60; i >= 0; i--){
if(s + (1ll << i) <= t){
s += (1ll << i);
ans++;
}
}
cout << ans << endl;
}
}
se1ka2