zoukankan      html  css  js  c++  java
  • ZOJ 3356 Football Gambling II

     

    Football Gambling II

    Time Limit: 3 Seconds      Memory Limit: 65536 KB

    The 2010 FIFA World Cup toke place between 11 June and 11 July 2010 in South Africa. Being a non-fans, asmn likes football gambling more than the football match itself. Of course, he won't use real money, he just gamble on the renren.com for fun using the virtual gold coin.

    ZOJ 3356 Football Gambling II - qhn999 - 码代码的猿猿

    The rule of football gambling is simple. The bookmaker display three decimal numbers abc before the match between team X and team Y. Number a is the odds for team X will win the game. Number b is the odds for they will get a draw. Number c is the odds for team X will lose the game.

    Odds means that if you bet x gold coins, you will get floor(odds * x) gold coins in total if you guess the right result, or you will get nothing.

    The Odds of the online gambling is higher than that in the real gambling because the gold coins are virtual. After several gambling, asmn found that, sometimes the odds are too high that it is possible to find a way to bet on three result at the same time, so that he can win money whatever the result is.

    After several gambling, asmn lose a lot of money. So he decide not to take any risk in the following gambling. Now, given that asmn has s gold coins before each match and the odds for this math, you should caluate the maximum number of coins asmn will have after the gambling in the worst situation.

    Input

    The input consists of N cases. The first line of the input contains a positive integer N(N <= 100). Each case contains an integer and three decimal numbers sab and c (0 <coins < 1000000, 1 < ab,c < 100), the meaning of which is described above. Each decimal number will have exactly two digits after the decimal point.

    Output

    For each case, output the maximum number of coins that asmn will have after the match in the worst situation.

    Sample Input

    4
    3 3.30 3.30 3.30
    30 3.30 3.30 3.30
    1 30.00 50.00 20.00
    42 2.00 3.00 7.00

    Sample Output

    3
    33
    1
    43

    Hint

    In the third case, the odds are very high, but asmn has only one coin. If he join the gambling, he may lost his last coin.


    Author: WANG, Yelei
    Source: ZOJ Monthly, July 2010

    来自:
    ゆっくりでいいさ
    このblogはwatashiの平凡な日常を淡々と描く物です。過度な期待はしないでください。


    从0到s枚举并模拟下注总金额,每一次都应该把这一元钱押到当前三种情况中收益最小的一个。一个优化就是先把大部分的钱都按b*cc*aa*b的比率下注,然后one by one的枚举。集训的时候我暴力枚举TLE了,而范叔只枚举-3到+3瞬秒,不过放Monthly的时候我把实现加到暴力枚举全部也能AC了。
    #include <iostream>
    #include <cstdio>
    #include <cstring>
    #include <algorithm>

    using namespace std;

    int main()
    {
        int re;
        long long int a,b,s,c[3],d[3],e[3],ans;
        scanf("%d",&re);
        while(re--)
        {
            scanf("%lld",&s);
            for(int i=0;i<3;i++)
            {
                scanf("%lld.%lld",&a,&b);
                c=a*100+b;
            }
            ans=0;
            d[0]=d[1]=d[2]=0;
            e[0]=e[1]=e[2]=0;
            for(int i=1;i<=s;i++)
            {
                int k=min_element(e,e+3)-e;
                d[k]++;
                e[k]=d[k]*c[k]/100;
                ans=max(ans,*min_element(e,e+3)-i);
            }
            printf("%lld ",ans+s);
        }

        return 0;
    }
    * This source code was highlighted by YcdoiT. ( style: Codeblocks )

    ゆっくりでいいさ

    ゆっくりでいいさゆっくりでいいさゆっくりでいいさゆっくりでいいさ
    このblogはwatashiの平凡な日常を淡々と描く物です。過度な期待はしないでください。

    ゆっくりでいいさ

    ゆっくりでいいさゆっくりでいいさゆっくりでいいさゆっくりでいいさ
     
    このblogはwatashiの平凡な日常を淡々と描く物です。過度な期待はしないでください
  • 相关阅读:
    【IoT平台北向API调用】使用Postman调用Https接口
    【LiteOS】LiteOS移植常见问题
    搞IT产品,请谨记Mobile First
    Modelarts与无感识别技术生态总结(浅出版)
    高性能Web动画和渲染原理系列(1)——CSS动画和JS动画
    使用蓝图构建Flask项目目录
    一统江湖的大前端(8)- velocity.js 运动的姿势(上)
    只需两步手把手教你玩转图像识别
    秉承初心,砥砺奋进!华为云助力锦江都城开启云服务时代
    HBase 索引创建
  • 原文地址:https://www.cnblogs.com/CKboss/p/3350894.html
Copyright © 2011-2022 走看看