题目链接 点我
题意:有n种药串在一起,医生只记得放的顺序。现在让你找到最短的链 使得医生在黑暗中也可以找到想要的药。
思路:对称,答案 为 2*n-1。
AC代码:
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <map>
#include <string>
#include <vector>
#define lson o<<1|1, l, mid
#define rson o<<1, mid+1, r
#define ll o<<1
#define rr o<<1|1
#define INF 0x3f3f3f3f
#define eps 1e-8
#define debug printf("1\n")
#define MAXN 10000
#define MAXM 100000
#define LL long long
#define FOR(l, r, d) for(int i = l; i <= r; i+=d)
#define CLE(a, b) memset(a, (b), sizeof(a))
#define W(a) while(a--)
#define Ri(a) scanf("%d", &a)
#define Pi(a) printf("%d\n", (a))
#define Rl(a) scanf("%lld", &a)
#define Pl(a) printf("%lld\n", (a))
using namespace std;
int main()
{
int t, kcase = 1;
scanf("%d", &t);
W(t)
{
LL n; Rl(n);
printf("Case #%d: ", kcase++);
Pl(2*n-1);
}
return 0;
}