最短路 1 (2019 年百度之星·程序设计大赛 - 初赛三)

Problem Description
有一张  n 个点的完全无向图,点的标号是 1...n,其中边 (i,j) 的长度是 i xor j,现在你需要求出点 1 到点 n 的最短路的长度。
 

 

Input
第一行一个正整数  T 表示数据组数 1T100

对于每组数据:第一行一个正整数 n 表示点数 (2n105)
 

 

Output
输出  T 行,每行一个整数表示点 1 到点 n 的最短路
 

 

Sample Input
1 3
 

 

Sample Output
2
 
#include <bits/stdc++.h>
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <string>
#include <cstring>
#include <cstdlib>
#include <map>
#include <vector>
#include <set>
#include <queue>
#include <stack>
#include <cmath>
const int INT=1e6+5;
typedef long long ll;
#define pql priority_queue<ll>
#define pq priority_queue<int>
#define v vector<int>
#define vl vector<ll>
#define lson rt<<1, l, m  
#define rson rt<<1|1, m+1, r
#define read(x) scanf("%d",&x)
#define lread(x) scanf("%lld",&x);
#define pt(x) printf("%d\n",(x))
#define yes printf("YES\n");
#define no printf("NO\n");
#define gcd __gcd
#define cn cin>>
#define ct cout<<
#define en <<endl
#define rep(j,k) for (int i = (int)(j); i <= (int)(k); i++)
#define input(k) for (int i = 1; i <= (int)(k); i++)  {cin>>a[i] ; }
#define mem(s,t) memset(s,t,sizeof(s))
#define re return 0;
#define TLE std::ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define mod(x) ((x)%9973)
using namespace std;
const int maxn =11;
int n,t;
int main()
{
    for(cn t;t;t--)
    {
        cn n;
        ct (n^1) en;
    }
    re;
}

 

转载于:https://www.cnblogs.com/Shallow-dream/p/11424826.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值