Contents

//题目大意:
//有个人想买酒,手头上有买n瓶酒的钱,买了n瓶酒,现在酒店有促销活动,3个空瓶可以换一瓶,4个瓶盖换一瓶
//问换完后总共可以喝多少瓶酒

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28

#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <iostream>
#include <algorithm>
using namespace std;


int main()
{

int T;
int a,b, n, tmp1, tmp2;
scanf("%d", &T);
while(T--){
scanf("%d", &n);
a = b = n;
while(a / 3 != 0 || b / 4 != 0){
n = a / 3 + b / 4 + n;
tmp1 = a / 3;
tmp2 = b / 4;
a = a / 3 + a % 3 + tmp2;//主要是这里有坑
b = b / 4 + b % 4 + tmp1;
}
printf("%d\n", n);
}
return 0;
}
Contents