zoukankan      html  css  js  c++  java
  • LightOJ 1027 概率

    平均访问时间为sum(t)/n,期望次数为n/n1

    #include <cstdio>
    #include <cstdlib>
    #include <cstring>
    #include <cmath>
    #include <cctype>
    #include <vector>
    #include <stack>
    #include <queue>
    #include <map>
    #include <algorithm>
    #include <iostream>
    #include <string>
    #include <set>
    #define X first
    #define Y second
    #define sqr(x) (x)*(x)
    #pragma comment(linker,"/STACK:102400000,102400000")
    using namespace std;
    const double PI = acos(-1.0);
    map<int, int>::iterator it;
    typedef long long LL ;
    template<typename T> void checkmin(T &x, T y) {x = min(x, y);}
    template<typename T> void checkmax(T &x, T y) {x = max(x, y);}
    
    
    int main() {
        int T, n;
        scanf("%d", &T);
        for(int t = 1; t <= T; ++t) {
            scanf("%d", &n);
            int n1 = 0, sum = 0;
            for(int i = 0; i < n; ++i) {
                int a;
                scanf("%d", &a);
                if(a > 0)++n1;
                sum += abs(a);
            }
            printf("Case %d: ", t);
            if(n1==0) {
                puts("inf");
            }
            else {
                int g = __gcd(sum, n1);
                printf("%d/%d
    ", sum/g, n1/g);
            }
        }
        return 0;
    }
  • 相关阅读:
    P1726 上白泽慧音
    P1993 小k的农场
    P1983 车站分级
    P1525 关押罪犯【二分+二分图】
    P1268 树的重量【构造】
    P1113 杂务
    F.Three pahs on a tree
    P1522 牛的旅行
    两个约束下的dp问题
    dp 最大正方形
  • 原文地址:https://www.cnblogs.com/cxw199204/p/3348527.html
Copyright © 2011-2022 走看看