题解:UVA12992 Huatuo's Medicine
saixingzhe · · 题解
题意
华佗去病人家看病,当他需要携带两种药物时,例如药物 A 和 B,他将把 A 放在一个瓶子里,把 B 放在两个瓶子里。然后他会按 -B-A-B- 的顺序把瓶子锁起来。
要求出华佗带
分析
我们模拟一下,带 -C-B-A-B-C- 需要 -D-C-B-A-B-C-D- 需要
不难看出,
有了等式,代码就简单了,上代码。
代码
#include<bits/stdc++.h>
using namespace std;
int T,n;
int main(){
cin>>T;
for(int i=1;i<=T;i++){
cin>>n;
cout<<"Case #"<<i<<":"<<' '<<n*2-1<<endl;
}
}