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 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 integersA1, 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 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; }