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;
    }
  • 相关阅读:
    Lucene.Net
    授权
    测试
    Upgrade ASP.NET 1.1 To ASP.NET 2.0 Cookie
    Highlight
    缓存
    base
    System.Environment.UserDomainName 为什么不返回 当前的 Domainname
    英语骂人一百句
    比较动态调用代码
  • 原文地址:https://www.cnblogs.com/cxw199204/p/3348527.html
Copyright © 2011-2022 走看看