Codeforces Gym100425 H. Football Bets

H. Football Bets
time limit per test
1 second
memory limit per test
128 megabytes
input
standard input
output
standard output

While traveling to England, it is impossible not to catch the English passion for football. Almost everyone here is involved in football life: some play, others are watching, and the most risky ones bet on the results.

Before the start of the next season of English Premier League, a certain bookmaker office has launched a new option. In order to participate, players must bet a fixed (same for all) amount of money on one of the N teams participating in the championship. All players who guessed a team that will be the champion get back their owh bets. Additionally, they share equally one half of all bets made on the other teams.

During this event, at least one player made a bet, each player made exactly one bet on some of the teams, no teams received more than K bets, and at the end of the tournament, the bookmaker’s office reported a profit of exactly P percent of the total amount of bets.

Find any distribution of bets between teams which satisfies the above requirements, or determine that no such distribution exists.

Input

The input contains one line with three integers N, K and P: the number of teams in the football tournament, the maximum possible number of bets on the one team and the profit reported by the bookmaker’s office (2 ≤ N ≤ 100, 1 ≤ K ≤ 100, 0 ≤ P ≤ 100).

Output

If no distribution satisfying the requirements exists, print 0 on a separate line.

Otherwise, on the first line, print one integer W: the number of the winning team (1 ≤ W ≤ N). The second line must contain N integers A1, A2, , AN where Ai is the number of bets on i-th team (0 ≤ Ai ≤ K). Note that the team order is arbitrary, but the number of winning team must fit this order. If there are several solutions, print any one of them.

Sample test(s)
Input
4 100 10
Output
2
10 80 5 5
Input
2 4 40
Output
1
1 4
Input
5 10 23
Output
0

题意

胡说有一个彩票站,有 N 支球队比赛,至少有一个人对其中一个队下注,每个人下注的金额相同,每支球队最多被下注金额为K,赌赢的人会拿回自己的赌注,并把其他队伍的赌注的一半当作奖金均分,剩余的赌注是彩票站的利润,利润率 P% ,现在给出 N,K,P ,要求构造一个长度为 N 的满足要求的序列,表示每个球队的赌注金额,并输出获胜球队的编号。

题解

设获胜队的赌注为x,失败球队的赌注为 y ,那么P/100=y2y+x,整理后得 y=Px50P x 范围很小,直接暴力枚举出满足y是整数的 x 就可以了。坑点在于,可能没有赌赢的人,这时候胜利队的赌注为0,其他队之和大于0。否则的话P一定是小于 50 的。(代码队友写的。。我就负责找坑来的。。。)

代码

#include <bits/stdc++.h>
using namespace std;
int n, k, p,sum;
int main()
{
    //freopen("in.txt", "r", stdin);
    scanf("%d%d%d", &n, &k, &p);
    if(p==100)
    {
        printf("1\n0 ");
        for(int i=1;i<n;i++)
            printf("1 ");
        return 0;
    }
    else if (p>=50)
    {
        printf("0");
        return 0;
    }
    else if (p == 0)
    {
        printf("1\n1");
        for (int i = 2; i <= n; i++)
            printf(" 0");
        return 0;
    }
    for(int i=1;i<=k;i++)
    {
        if((p*i)%(50-p)==0)
        {
            sum=(p*i)/(50-p);
            if(sum<=(n-1)*k)
            {
                printf("1\n");
                printf("%d ",i);
                for(int j=1;j<n;j++)
                {
                    if(sum>=k)
                    {
                        printf("%d ",k);
                        sum-=k;
                    }
                    else if(sum)
                    {
                        printf("%d ",sum);
                        sum=0;
                    }
                    else
                        printf("0 ");
                }
                return 0;
            }
        }
    }
    printf("0");
    return 0;
}
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值