4.26腾讯笔试,被虐的交卷先出来了。。
抛开两道数据结构题不说,
剩下三道题里面, 最小距离不会找, 翻转不会翻,就写出来个找根节点。。。
今日自闭(1/1)
贴个根节点的代码,现在22:15,考试结束了
#include <iostream>
#include <bits/stdc++.h>
#include <string.h>
#include <stdio.h>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <set>
#include <map>
using namespace std;
inline long long pow(int a,int b){
long long re=1, base = a;
while(b){
if(b&1)
re*=base;
base*=base;
b>>=1;
}
return re;
}
long long x,y;
int q,k;
//
int main()
{
//cin>>q;
scanf("%d",&q);
while(q--) {
//cin >> x >> k;
scanf("%lld %d", &x,&k);
y = pow(2,k);
if (x < y) {
printf("%d\n",-1);
} else {
while(x>=y){
x>>=1;
}
printf("%lld\n",x);
}
}
return 0;
}
话说赛制可以骗分么,肉眼看暴力过不了直接放弃了。。。。要是能骗分我就衰了

