/ Randle /

记录详情

Accepted

/in/foo.cc: In function 'int main()':
/in/foo.cc:28:22: warning: format '%d' expects argument of type 'int', but argument 2 has type 'long long int' [-Wformat=]
   printf("%d\n",total);
                      ^
# 状态 耗时 内存占用
#1 Accepted 1ms 272.0 KiB
#2 Accepted 1ms 204.0 KiB
#3 Accepted 1ms 208.0 KiB
#4 Accepted 1ms 200.0 KiB
#5 Accepted 1ms 212.0 KiB
#6 Accepted 1ms 208.0 KiB
#7 Accepted 6ms 268.0 KiB
#8 Accepted 6ms 196.0 KiB
#9 Accepted 6ms 300.0 KiB
#10 Accepted 6ms 196.0 KiB

代码

#include <cstdio>
#include <queue>

std::queue<int> stack;

int main()
{
	int n;
	scanf("%d",&n);
	for(int i=0;i<n;i++){
		int from,to;
		scanf("%d%d",&from,&to);
		while(from>0){
			stack.push(from);
			from>>=1;
		}
		long long total=0;
		while(to>0){
			while(stack.front()>to){
				stack.pop();
				total++;
			}
			if(stack.front()==to) break;
			total++;
			to>>=1;
		}
		while(!stack.empty()) stack.pop();
		printf("%d\n",total);
	}
	return 0;
}

信息

递交者
类型
递交
题目
三向城T1
题目数据
下载
语言
C++
递交时间
2019-12-13 14:29:24
评测时间
2019-12-13 14:29:24
评测机
分数
100
总耗时
34ms
峰值内存
300.0 KiB