zoukankan      html  css  js  c++  java
  • hdu1437

    这个地方用g++居然错了,吾自测正确

    解决方法是在测试平台上用光所有编译器,选c编译器时正确

    要相信自己

    /*
     * =====================================================================================
     *
     *       Filename:  1437.c
     *
     *
     *        Version:  1.0
     *        Created:  2013年11月23日 13时00分07秒
     *       Revision:  none
     *       Compiler:  gcc
     *
     *         Author:  Wenxian Ni (Hello World~), niwenxianq@qq.com
     *   Organization:  AMS/ICT
     *
     *天气情况
    
    Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)
    Total Submission(s): 574    Accepted Submission(s): 227
    
    
    Problem Description
    如果我们把天气分为雨天,阴天和晴天3种,在给定各种天气之间转换的概率,例如雨天转换成雨天,阴天和晴天的概率分别为0.4,0.3,0.3.那么在雨天后的第二天出现雨天,阴天和晴天的概率分别为0.4,0.3,0.3.现在给你今天的天气情况,问你n天后的某种天气出现的概率.
     
    
    Input
    我们这里假设1,2,3分别代表3种天气情况,Pij表示从i天气转换到j天气的概率.
    首先是一个数字T表示数据的组数.
    每组数据以9个数开始分别是P11,P12,P13,……,P32,P33,接着下一行是一个数字m,表示提问的次数。每次提问有3个数据,i,j,n,表示过了n天从i天气情况到j天气情况(1<=i,j<=3 1<=n<=1000)。
     
    
    Output
    根据每次提问输出相应的概率(保留3位小数)。
     
    
    Sample Input
    1
    0.4 0.3 0.3 0.2 0.5 0.3 0.1 0.3 0.6
    3
    1 1 1
    2 3 1
    1 1 2
     
    
    Sample Output
    0.400
    0.300
    0.250
    
    
    Hint:如果GC提交不成功,可以换VC试试    Description:  
     * =====================================================================================
     */
    
    #include<stdio.h>
    #include<string.h>
    
    
    int main()
    {
        int ncase;
        int startd, endd, n;
        int i, j, ask;
        float p[3][3];
        float pend0, pend1, pend2;
        float pend0_t, pend1_t, pend2_t;
        scanf("%d",&ncase);
        while(ncase--)
        {
            for(i=0;i<3;i++) 
            for(j=0;j<3;j++) 
            scanf("%f",&p[i][j]);
            scanf("%d",&ask);
            while(ask--)
            {
                pend0 = pend1 = pend2 = 1.0;
                scanf("%d %d %d",&startd, &endd, &n); 
                pend0 = pend0_t = p[startd-1][0]; 
                pend1 = pend1_t = p[startd-1][1]; 
                pend2 = pend2_t = p[startd-1][2]; 
                for(i=2;i<=n;i++)
                {
                    pend0_t = pend0;
                    pend1_t = pend1;
                    pend2_t = pend2;
                    pend0 = p[0][0]*pend0_t + p[1][0]*pend1_t + p[2][0]*pend2_t;
                    pend1 = p[0][1]*pend0_t + p[1][1]*pend1_t + p[2][1]*pend2_t;
                    pend2 = p[0][2]*pend0_t + p[1][2]*pend1_t + p[2][2]*pend2_t;
                }
                if(endd==1)
                {
                    printf("%.3f
    ",pend0);
                    continue;
                }
                if(endd==2)
                {
                    printf("%.3f
    ",pend1);
                    continue;
                }
                if(endd==3)
                {
                    printf("%.3f
    ",pend2);
                    continue;
                }
            }
        }
        return 0;
    }
    


    每天早上叫醒你的不是闹钟,而是心中的梦~
  • 相关阅读:
    GCC编绎详解
    GUN C/C++ __attribute__ 用法 转
    rust 参考的资料 转
    Eclipse环境安装rust
    GNU Debugger for Windows----GDB
    minGW cygwin gnuwin32
    tdm-gcc
    GNU tools
    The MinGW and mingw-w64 projects.----GCC
    crosstool-NG
  • 原文地址:https://www.cnblogs.com/vintion/p/4117010.html
Copyright © 2011-2022 走看看