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 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 = ;
if (p == )
{
cout << << endl;
cout << ;
for(int i = ; i <= n ; ++ i) cout << " " <<k;
cout << endl;
return ;
}
for(int x = ; x <= ed ; ++ x)
{
if (x*p % == )
{
y = x - (x*p)/;
if (y > && y <= k && (x-y) <= (n-)*k)
{
ok = ;
tx = x;
break;
}
}
}
sb = tx-y;
if (!ok) printf("0\n");
else
{
cout << << endl;
cout << y ;
for(int i = ; i <= n ; ++ i)
{
cout << " ";
if (sb >= k)
{
cout << k;
sb -=k;
}
else
{
cout << sb;
sb = ;
}
}
cout << endl;
}
return ;
}
Codeforces Gym 100425H H - Football Bets 构造的更多相关文章
- Codeforces Gym 100187K K. Perpetuum Mobile 构造
K. Perpetuum Mobile Time Limit: 2 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/gym/100187/pro ...
- codeforces Gym 100187H H. Mysterious Photos 水题
H. Mysterious Photos Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/gym/100187/p ...
- codeforces Gym 100500H H. ICPC Quest 水题
Problem H. ICPC QuestTime Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/gym/100500/a ...
- Codeforces Gym 100114 H. Milestones 离线树状数组
H. Milestones Time Limit: 1 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/gym/100114 Descripti ...
- codeforces gym 100357 H (DP 高精度)
题目大意 有r*s张扑克牌,数字从1到 r,每种数字有s种颜色. 询问对于所有随机的d张牌,能选出c张组成顺子的概率和组成同花的概率. 解题分析 对于组成顺子的概率,令dp[i][j][k]表示一共选 ...
- codeforces gym 100286 H - Hell on the Markets (贪心算法)
题目链接 题意:n个数分别为a[i],问是否存在一组对应的b[i],b[i]=1 || b[i]=-1,使得ai*bi的n项和为0. 题解: 先证明一个结论吧,对于1≤ai≤i+1,前面ai个数一定可 ...
- Codeforces gym 101343 J.Husam and the Broken Present 2【状压dp】
2017 JUST Programming Contest 2.0 题目链接:Codeforces gym 101343 J.Husam and the Broken Present 2 J. Hu ...
- Codeforces GYM 100876 J - Buying roads 题解
Codeforces GYM 100876 J - Buying roads 题解 才不是因为有了图床来测试一下呢,哼( 题意 给你\(N\)个点,\(M\)条带权边的无向图,选出\(K\)条边,使得 ...
- Codeforces Gym 101252D&&floyd判圈算法学习笔记
一句话题意:x0=1,xi+1=(Axi+xi%B)%C,如果x序列中存在最早的两个相同的元素,输出第二次出现的位置,若在2e7内无解则输出-1. 题解:都不到100天就AFO了才来学这floyd判圈 ...
随机推荐
- ecshop 二次开发及模板标签
ecs_account_log // 用户账目日志表 ecs_activity // 活动表(代码,名称,开始,结束,描述) ecs_ad // 广告表(位置,类型,名称,链接,图片,开始,结 ...
- DevExpress控件使用小结 z
.TextEditor(barEditItem)取文本 string editValue = barEditItem1.EditValue.ToString(); //错误,返回null string ...
- 《Python CookBook2》 第一章 文本 - 过滤字符串中不属于指定集合的字符 && 检查一个字符串是文本还是二进制
过滤字符串中不属于指定集合的字符 任务: 给定一个需要保留的字符串的集合,构建一个过滤函数,并可将其应用于任何字符串s,函数返回一个s的拷贝,该拷贝只包含指定字符集合中的元素. 解决方案: impor ...
- TRANSLATE
语法格式: TRANSLATE(expr, from_string, to_string) 示例如下: SELECT TRANSLATE('ab 你好 bcdefg', 'abcdefg', '123 ...
- 学习笔记之Linux内核编译过程
准备工作 物理主机:win8(32位) 虚拟机工具:VirtualBox_4.3.16_Win32 虚拟主机:xubuntu-12.04.4 安装virtualBox功能增强包 设置好虚拟机与主机的共 ...
- Tkinter教程之Listbox篇
本文转载自:http://blog.csdn.net/jcodeer/article/details/1811310 #Tkinter教程之Listbox篇#Listbox为列表框控件,它可以包含一个 ...
- .net组件技术
.NET是什么? •.NET是一个平台,而不是一种语言. •.NET是Microsoft的用以创建XML Web服务(下一代软件)平台,该平台将信息.设备和人以一种统一的.个性化的方式联系起来. ...
- Node.js 数据库实时监控库 node-dbmon
node-dbmon 是一个 Node.js 数据库实时监控库,如果你希望在数据库表数据更改后,或者是文件修改后能更新 GUI,那么这个库正好适合你. https://github.com/strap ...
- #JAVA操作LDAP
package com.wisdombud.unicom.monitor.ldap; import java.util.ArrayList; import org.slf4j.Logger; impo ...
- ISP与IAP的区别
转: ISP(In-System Programming)在系统可编程,指电路板上的空白器件可以编程写入最终用户代码, 而不需要从电路板上取下器件,已经编程的器件也可以用ISP方式擦除或再编程.IAP ...