Codeforces Gym 100425H H - Football Bets 构造

H - Football Bets
Time Limit: 20 Sec

Memory Limit: 256 MB

题目连接

http://acm.hust.edu.cn/vjudge/contest/view.action?cid=87493#problem/H

Description

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 Kbets, 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 NK 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 integersA1A2..., 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 Input

4 100 10

Sample Output

2

10 80 5 5

HINT

 

题意

有n个队伍,每场比赛最多压k元钱,其中赌场要赚p%元

让你构造出来一个合法组合

题解

暴力枚举就好了,假设x为总的金额,y为压冠军队的钱

因为数据范围很小,所以直接暴力枚举

注意几个坑就吼了

代码:

#include <iostream>
#include <cstring>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <stack>
#include <map>
#include <set>
#include <queue>
#include <iomanip>
#include <string>
#include <ctime>
#include <list>
#include <bitset>
typedef unsigned char byte;
#define pb push_back
#define input_fast std::ios::sync_with_stdio(false);std::cin.tie(0)
#define local freopen("in.txt","r",stdin)
#define pi acos(-1)

using namespace std;
int n , k , p;
int sb;
int y;
int tx;

int main(int argc,char *argv[])
{
  cin >> n >> k >> p;
  int ed = n * k ;
  int ok = 0;
  if (p == 100)
  {
      cout << 1 << endl;
      cout << 0;
      for(int i = 2 ; i <= n ; ++ i) cout << " " <<k;
      cout << endl;
    return 0;
  }
  for(int x = 1 ; x <= ed ; ++ x)
  {
      if (x*p % 50 == 0)
      {
          y = x - (x*p)/50;
           if (y > 0 && y <= k && (x-y) <= (n-1)*k)
          {
              ok = 1;
              tx = x;
              break;
          }
      }
  }
  sb = tx-y;
  if (!ok) printf("0\n");
  else
  {
       cout << 1 << endl;
       cout << y ;
       for(int i = 2 ; i <= n ; ++ i)
       {
           cout << " ";
           if (sb >= k)
           {
               cout << k;
               sb -=k;
           }
           else
           {
               cout << sb;
               sb = 0;
           }
       }
       cout << endl;
  }
  return 0;
}

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值