E-邝博士的问题-中南林业科技大学第十一届程序设计大赛

链接:https://www.nowcoder.com/acm/contest/124/E
来源:牛客网

题目描述
ACM校赛已经到来了,鉴于有些萌新对于ACM-ICPC发奖制度有些不清楚,我们现在来普及一下。在现场赛:金奖占总队伍数的10%,银奖占其总20%,铜奖占其30%,剩下40%拿一手铁牌。那么是向上取整呢还是向下取整呢?一般来说是向下取整的。但是如果运气好碰到了主办方向上取整呢,会增加多少队伍获奖呢?

帅气的邝博士请你计算一下,向上取整相比向下取整,由银变金、由铜变银、由铁变铜的队伍数!

即:
原来在银牌区的队伍因为金牌数量增加跑到了金牌区!
原来在铜牌区的队伍因为金银牌数量增加跑到了银牌区!
原来在铁牌区的队伍因为金银铜牌数量增加跑到了铜牌区!
输入描述:
多组数据,每一组输入一个n ,表示一共有多少支队伍参赛
输出描述:
每一个样例输出在一行,输出三个数字,中间用一个空格隔开
示例1
输入

185
输出

1 1 2

[分析]
金牌区间多的人会影响后面银牌和铜牌的人,相应地加上金牌多的人数
银牌同理

[代码]

#include<cstdio>
#include<algorithm>
#include<cstring>
#include<algorithm>
#include<vector>
using namespace std;
typedef long long ll;
#define MOD  1000000007
int main()
{

    int n;
    while (scanf("%d", &n) != EOF)
    {
        int num1 = n*0.1 + 0.999999;
        int num2 = n*0.1;
        int ans1 = num1 - num2;
        printf("%d", ans1);

        num1 = n*0.2 + 0.999999;
        num2 = n*0.2;
        int ans2 = num1 - num2 + ans1;
        printf(" %d", ans2);

        num1 = n*0.3 + 0.999999;
        num2 = n*0.3;
        int ans3 = num1 - num2 + ans2;
        printf(" %d\n", ans3);
    }
}

/*/185

18.5
19 18

37

*/

猜你喜欢

转载自blog.csdn.net/q435201823/article/details/80384932
今日推荐