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判圈 ...
随机推荐
- 【转】那些不能错过的Xcode插件 -- 不错不错
原文网址:http://www.cocoachina.com/industry/20130918/7022.html 古人云“工欲善其事必先利其器”,打造一个强大的开发环境,是立即提升自身战斗力的绝佳 ...
- 给table中某一列的文字右对齐
一般来说,没写过jquery的前端人员,肯定是定义一个class,给每一行的那列加上align_r{text-align:right}.这是很麻烦的. 所以用jquery来写,可以$("ta ...
- C# 委托总结
总结 委托的本质: 委托是一种特殊的数据类型,它表示某种特定类型的函数,并且可以表示多个函数,将这些函数串联起来.使用委托就好像函数调用一样. 委托实质上是一个类,编译器会根据关键字delegate自 ...
- 翻译【ElasticSearch Server】第一章:开始使用ElasticSearch集群(3)
运行ElasticSearch(Running ElasticSearch) 让我们运行我们的第一个实例.转到bin目录并从命令行运行以下命令: ./elasticsearch –f (Linux o ...
- 【QTP】自动化测试:
一.参数化: 1.随机数: 下面两个语句都可以: Window("Flight Reservation").Dialog("Flights Table").Wi ...
- 细雨学习笔记:Jmeter测试计划最基本的元素
测试计划-用户组下最基本的元素: 1)HTTP请求默认值 2)HTTP Cookie 管理器(有些操作需要登录后才能访问,用户信息记录在Cookie中,各请求之间就可以共享Cookie了) 3)请求S ...
- void、void*以及NULL
void.void*以及NULL 写在前面 在使用C++的过程中,void和NULL用到的频率挺高的,但是从来没有去探索过这两个关键字的联系和区别,也没有对它们做更多的探索.对于void*,说实话,实 ...
- 将string转化为char*的方法
在构造文件流变量时候发现,fstream的第一个参数,即文件路径必须是const char * 如: string s = "/home/user/1.txt"; fstream ...
- Apache Spark Shark的简介
Shark是构建在Spark和Hive基础之上的数据仓库. 目前,Shark已经完成学术使命,终止开发,但其架构和原理仍具有借鉴意义. 它提供了能够查询Hive中所存储数据的一套SQL接口,兼容现有的 ...
- 现代程序设计 homework-09
现代程序设计 homework-09 这次作业是要求将homework-02做成一个可演示的应用,目的是为了让用户看到程序的计算步骤以及中间结果. 借此机会也学了一下JavaScript,感觉总结的地 ...