結果
| 問題 |
No.1742 Binary Indexed Train
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2021-11-12 21:47:23 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 260 ms / 3,000 ms |
| コード長 | 277 bytes |
| コンパイル時間 | 559 ms |
| コンパイル使用メモリ | 63,616 KB |
| 実行使用メモリ | 5,248 KB |
| 最終ジャッジ日時 | 2024-11-25 17:57:21 |
| 合計ジャッジ時間 | 7,123 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 32 |
コンパイルメッセージ
main.cpp:4:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
4 | main()
| ^~~~
ソースコード
#include<iostream>
using namespace std;
int N,Q;
main()
{
cin>>N>>Q;
for(;Q--;)
{
long S,T;
cin>>S>>T;
int cnt=0;
while(S<T)
{
long i=S&-S;
if(i>0&&S+i<=T)S+=i,cnt++;
else
{
cnt+=__builtin_popcountll(T-S);
S=T;
}
}
cout<<cnt<<endl;
}
}