結果

問題 No.1742 Binary Indexed Train
ユーザー kotatsugamekotatsugame
提出日時 2021-11-12 21:47:23
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 273 ms / 3,000 ms
コード長 277 bytes
コンパイル時間 496 ms
コンパイル使用メモリ 63,728 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-08-17 00:51:43
合計ジャッジ時間 7,381 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 AC 230 ms
4,380 KB
testcase_04 AC 227 ms
4,376 KB
testcase_05 AC 231 ms
4,380 KB
testcase_06 AC 162 ms
4,376 KB
testcase_07 AC 164 ms
4,380 KB
testcase_08 AC 267 ms
4,380 KB
testcase_09 AC 271 ms
4,376 KB
testcase_10 AC 273 ms
4,376 KB
testcase_11 AC 267 ms
4,376 KB
testcase_12 AC 270 ms
4,376 KB
testcase_13 AC 226 ms
4,380 KB
testcase_14 AC 230 ms
4,380 KB
testcase_15 AC 58 ms
4,376 KB
testcase_16 AC 41 ms
4,376 KB
testcase_17 AC 188 ms
4,380 KB
testcase_18 AC 176 ms
4,376 KB
testcase_19 AC 101 ms
4,376 KB
testcase_20 AC 9 ms
4,376 KB
testcase_21 AC 68 ms
4,380 KB
testcase_22 AC 197 ms
4,380 KB
testcase_23 AC 14 ms
4,380 KB
testcase_24 AC 7 ms
4,376 KB
testcase_25 AC 140 ms
4,376 KB
testcase_26 AC 110 ms
4,376 KB
testcase_27 AC 127 ms
4,380 KB
testcase_28 AC 19 ms
4,380 KB
testcase_29 AC 187 ms
4,376 KB
testcase_30 AC 81 ms
4,376 KB
testcase_31 AC 219 ms
4,376 KB
testcase_32 AC 78 ms
4,376 KB
testcase_33 AC 27 ms
4,380 KB
testcase_34 AC 140 ms
4,380 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp:4:1: 警告: ISO C++ では型の無い ‘main’ の宣言を禁止しています [-Wreturn-type]
    4 | main()
      | ^~~~

ソースコード

diff #

#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;
	}
}
0