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为压冠军队的钱

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

注意几个坑就吼了

代码:

  1. #include <iostream>
  2. #include <cstring>
  3. #include <cstdio>
  4. #include <algorithm>
  5. #include <cmath>
  6. #include <vector>
  7. #include <stack>
  8. #include <map>
  9. #include <set>
  10. #include <queue>
  11. #include <iomanip>
  12. #include <string>
  13. #include <ctime>
  14. #include <list>
  15. #include <bitset>
  16. typedef unsigned char byte;
  17. #define pb push_back
  18. #define input_fast std::ios::sync_with_stdio(false);std::cin.tie(0)
  19. #define local freopen("in.txt","r",stdin)
  20. #define pi acos(-1)
  21.  
  22. using namespace std;
  23. int n , k , p;
  24. int sb;
  25. int y;
  26. int tx;
  27.  
  28. int main(int argc,char *argv[])
  29. {
  30. cin >> n >> k >> p;
  31. int ed = n * k ;
  32. int ok = ;
  33. if (p == )
  34. {
  35. cout << << endl;
  36. cout << ;
  37. for(int i = ; i <= n ; ++ i) cout << " " <<k;
  38. cout << endl;
  39. return ;
  40. }
  41. for(int x = ; x <= ed ; ++ x)
  42. {
  43. if (x*p % == )
  44. {
  45. y = x - (x*p)/;
  46. if (y > && y <= k && (x-y) <= (n-)*k)
  47. {
  48. ok = ;
  49. tx = x;
  50. break;
  51. }
  52. }
  53. }
  54. sb = tx-y;
  55. if (!ok) printf("0\n");
  56. else
  57. {
  58. cout << << endl;
  59. cout << y ;
  60. for(int i = ; i <= n ; ++ i)
  61. {
  62. cout << " ";
  63. if (sb >= k)
  64. {
  65. cout << k;
  66. sb -=k;
  67. }
  68. else
  69. {
  70. cout << sb;
  71. sb = ;
  72. }
  73. }
  74. cout << endl;
  75. }
  76. return ;
  77. }

Codeforces Gym 100425H H - Football Bets 构造的更多相关文章

  1. Codeforces Gym 100187K K. Perpetuum Mobile 构造

    K. Perpetuum Mobile Time Limit: 2 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/gym/100187/pro ...

  2. codeforces Gym 100187H H. Mysterious Photos 水题

    H. Mysterious Photos Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/gym/100187/p ...

  3. codeforces Gym 100500H H. ICPC Quest 水题

    Problem H. ICPC QuestTime Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/gym/100500/a ...

  4. Codeforces Gym 100114 H. Milestones 离线树状数组

    H. Milestones Time Limit: 1 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/gym/100114 Descripti ...

  5. codeforces gym 100357 H (DP 高精度)

    题目大意 有r*s张扑克牌,数字从1到 r,每种数字有s种颜色. 询问对于所有随机的d张牌,能选出c张组成顺子的概率和组成同花的概率. 解题分析 对于组成顺子的概率,令dp[i][j][k]表示一共选 ...

  6. 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个数一定可 ...

  7. 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 ...

  8. Codeforces GYM 100876 J - Buying roads 题解

    Codeforces GYM 100876 J - Buying roads 题解 才不是因为有了图床来测试一下呢,哼( 题意 给你\(N\)个点,\(M\)条带权边的无向图,选出\(K\)条边,使得 ...

  9. Codeforces Gym 101252D&&floyd判圈算法学习笔记

    一句话题意:x0=1,xi+1=(Axi+xi%B)%C,如果x序列中存在最早的两个相同的元素,输出第二次出现的位置,若在2e7内无解则输出-1. 题解:都不到100天就AFO了才来学这floyd判圈 ...

随机推荐

  1. 【转】如何在IOS中使用3D UI - CALayer的透视投影

    原文网址:http://www.tairan.com/archives/2041/ 例子代码可以在 http://www.tairan.com/thread-3607-1-1.html 下载 iOS的 ...

  2. TCP/IP详解学习笔记(2)-数据链路层

    数据链路层有三个目的: 为IP模块发送和 接收IP数据报. 为ARP模块发送ARP请求和接收ARP应答. 为RARP发送RARP请 求和接收RARP应答 ip大家都听说过.至于ARP和RARP,ARP ...

  3. Conversion to Dalvik format failed: Unable to execute dex: null

    [2013-11-19 14:18:48 - Dex Loader] Unable to execute dex: java.nio.BufferOverflowException. Check th ...

  4. TabWidget/TabHost的两种使用方法

    1.概念 盛放Tab的容器就是TabHost.TabHost的实现有两种方式: 第一种继承TabActivity,从TabActivity中用getTabHost()方法获取TabHost.各个Tab ...

  5. matlab 学习

    http://blog.sina.com.cn/s/blog_7086379501012pc5.html <a href = "http://blog.sina.com.cn/s/bl ...

  6. Perfect Service

    题意: n个节点树,在一个节点放上一台服务器可以给相邻的其他各点提供服务且一个节点只能接受一台服务器,求使n个节点都被服务放的服务器的最小数量. 分析: 不算太难,状态想的差不多,但是考虑不全面状态方 ...

  7. HDU5807 Keep In Touch DP

    // HDU5807 Keep In Touch DP // 思路:直接暴力是O(n^6).所以要优化一下 // dp[i][j][k][0]:当前点i j k的方案数 // dp[i][j][k][ ...

  8. 微软Azure开始支持Docker技术

    前一段时间还在与微软的技术人员讨论媒体转换服务的效率问题,如果应用 Docker将会有质的提高,没想到国外的Azure已经开始支持了,相信国内Azure支持也不远了.微软正在努力确保Azure成为开发 ...

  9. C++ 之高效使用STL ( STL 算法分类)

    http://blog.csdn.net/zhoukuo1981/article/details/3452118

  10. numpy的矩阵运算

    矩阵赋值 >>> x1=np.arange(0,5) # array([0, 1, 2, 3, 4]) >>> x2=np.arange(1,6) # array( ...