BIT寒假练习-2013__1003:Exchange for Cola

来源:互联网 发布:网络筛子赌博技巧 编辑:程序博客网 时间:2024/05/16 08:47

换可乐,水题。

好像是小学奥数题,当时纠结了好久。

题目大意:

现在有N个盖子,用A个盖子能换B瓶可乐。当然你还能借老板几个瓶盖,喝完再换给他。(不科学啊,哪有那么好的老板-。-)

因为可以借无数个瓶盖,所以只考虑每次换可乐消耗掉的瓶盖数,A-B,然后看看N个盖子能换几次,最后乘上每次换的可乐瓶数,就是答案了。

#include <cstdio>#include <cstdlib>#include <iostream>#include <string>using namespace std;int n,a,b;int main(){while (scanf("%d%d%d",&n,&a,&b) == 3){      printf("%d\n",n/(a-b)*b);}return 0;}


原创粉丝点击