zoukankan      html  css  js  c++  java
  • HDOJ 1493 QQpet exploratory park


    QQpet exploratory park

    Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)
    Total Submission(s): 465    Accepted Submission(s): 244


    Problem Description
    Today, more and more people begin to raise a QQpet. You can get a lot of pleasure from it, although it does not have a real life and it calls for huge patience to take care of it. There is a place called QQpet exploratory park in the world. Every week, you can get a chance to have a joy there for free. The whole park contains 61 grids in a line, numbered from 0 to 60. Ten of them are important grids which will touch off ( 引发 ) an incident when the pet stands on. They are 5, 12, 22, 29, 33, 38, 42, 46, 50 and 55. Your pet is standing on the gird of number 0 in the beginning. You can toss the die ( 掷骰子 ) 10 times. Each time, the pet goes ahead n steps which n is the number from the die ( n ∈{ 1, 2, …, 6 } ). If your RP is great enough( calls RPG for short ), you will get many surprises in the important grids, such as some yuanbao( the money in QQpet world ), an improvement of your pet's ability, and the most attractive gift-package. Now, your task is to calculate the probability(概率) of touching each important grid.

    HDOJ 1493 QQpet exploratory park - qhn999 - 码代码的猿猿

     

    Input
    The first line of the input contains an integer t– determining the number of datasets. Then t lines follows. Each line contains 6 numbers pi, i ∈{ 1, 2, …, 6 }, indicating the probability of getting 1 to 6 after you toss the die every time . p1+ p2+ … + p6 = 1.
     

    Output
    For each test case, output the probability of touching each important grid. accurate up to 1 decimal places. There is a blank line between test cases. See the Sample Output to get the exactly output format.
     

    Sample Input
    20.000 1.000 0.000 0.000 0.000 0.000
    0.500 0.000 0.000 0.000 0.000 0.500
     

    Sample Output
    5: 0.0%
    12: 100.0%
    22: 0.0%
    29: 0.0%
    33: 0.0%
    38: 0.0%
    42: 0.0%
    46: 0.0%
    50: 0.0%
    55: 0.0%

    5: 3.1%
    12: 30.5%
    22: 27.3%
    29: 24.6%
    33: 21.9%
    38: 10.9%
    42: 0.8%
    46: 0.0%
    50: 4.4%
    55: 1.0%
     

    Author
    LL
     

    Source
     

    Recommend
    LL
     

    #include <iostream>
    #include <cstring>
    #include <cstdio>

    using namespace std;

    double p[7];
    double f[11][66];

    void dp()
    {
        for(int k=1;k<=10;k++)
        {
            for(int j=60;j>=1;j--)
            {
                for(int i=1;i<=6;i++)
                {
                    if(j>=i)
                    f[k][j]+=f[k-1][j-i]*p;
                }
            }
        }
    }


    int main()
    {
        int T;
        cin>>T;
        while(T--)
        {
            memset(f,0,sizeof(f));
            f[0][0]=1.0;
            for(int i=1;i<=6;i++)
                scanf("%lf",&p);
            dp();
            double ans=0;
            for(int i=1;i<=10;i++)
                ans+=f[5];
            printf("5: %.1lf%%\n",ans*100);
            ans=0;
            for(int i=1;i<=10;i++)
                ans+=f[12];
            printf("12: %.1lf%%\n",ans*100);
            ans=0;
            for(int i=1;i<=10;i++)
                ans+=f[22];
            printf("22: %.1lf%%\n",ans*100);
            ans=0;
            for(int i=1;i<=10;i++)
                ans+=f[29];
            printf("29: %.1lf%%\n",ans*100);
            ans=0;
            for(int i=1;i<=10;i++)
                ans+=f[33];
            printf("33: %.1lf%%\n",ans*100);
            ans=0;
            for(int i=1;i<=10;i++)
                ans+=f[38];
            printf("38: %.1lf%%\n",ans*100);
                    ans=0;
            for(int i=1;i<=10;i++)
                ans+=f[42];
            printf("42: %.1lf%%\n",ans*100);
                    ans=0;
            for(int i=1;i<=10;i++)
                ans+=f[46];
            printf("46: %.1lf%%\n",ans*100);
                    ans=0;
            for(int i=1;i<=10;i++)
                ans+=f[50];
            printf("50: %.1lf%%\n",ans*100);
                    ans=0;
            for(int i=1;i<=10;i++)
                ans+=f[55];
            printf("55: %.1lf%%\n",ans*100);

            if(T)
                putchar(10);
        }

        return 0;
    }



  • 相关阅读:
    Vue Cli3.0 使用jquery
    使用js加载器动态加载外部js、css文件
    通过js获取本机的IP地址
    $.ajax 中的contentType类型
    vue中 :style 与 :class 三元运算符使用
    bootstrap table checkbox获得选中得数据
    vscode自动生成文件头部注释和函数注释
    axios二次封装的几种方法
    vue组件库element-ui 的Table内容显示不更新
    Linux中iptables设置详细
  • 原文地址:https://www.cnblogs.com/CKboss/p/3351023.html
Copyright © 2011-2022 走看看