zoukankan      html  css  js  c++  java
  • Namomo Cockfight Round 4 t-shirt game

    传送门

    t-shirt

    根据题意写代码即可, 在区间内的所有排名得到衣服的概率和 乘 发生在区间内的概率, 然后用 1 除一下就可以了

    #define _rep(i,a,b) for(int i = (a); i <= (b); i++)
    void task1() {
        int t; cin >> t;
        while(t--) {
            int l,r, z = 0; cin >> l >> r;
            double p1 = 1.0/(r-l+1), ans = 0.0;
            //cout << " p1 = " << p1 << "
    ";
            _rep(i,l,r) 
            {
                ans += (1.0/(i));
            }
            cout << fixed << setprecision(10) << 1.0/(ans*p1) << "
    ";
        }
        return;
    }
    View Code

    game

    。。。一直wa,没注意细节  当有两个人都大于1金币时, 肯定结束不了  我知道这个但是写错了。。。。

    其实结论就是   第一个拥有金币的人操作完以后就赢了, 比如说只有他一个人拥有金币 namo 他肯定赢了  或者说还有一个人有且仅有一个金币 namo他把这个金币拿了 他也赢了, 其他情况都是游戏结束不了的

    #define _for(i,a,b) for(int i = (a); i < (b); i++)
    void task2() {
        int t; cin >> t;
        while(t--) {
            int n; cin >> n;    
            vector<int> a(n);
            int cnt1 = 0, cnt2 = 0, cnt3 = 0, f = 0;
            _for(i,0,n) {
                cin >> a[i];
                if(!f and a[i] >= 1) f = i+1;
                if(a[i] >= 1) cnt1++;
                else cnt3++;
            }
            if(cnt1 == 1) {cout << f << "
    "; continue;}
            
            if(cnt1 == 2) {
                for(int i = n-1; i >= 0; i--) 
                if(a[i] >= 1) {
                    if(a[i] == 1) cout << f << "
    ";
                    else cout << "namo
    ";
                    break;
                }
            } else cout << "namo
    ";
        }
        return;
    }
    View Code
  • 相关阅读:
    问题解决(2)
    问题解决(1)
    ubuntu16.04spyder闪退
    ubuntu16.04安装caffe
    python做批量剪切、旋转等小程序
    html中如何使得改变背景的透明度时,背景上的文字透明度不被改变
    css下拉菜单制作
    float浮动
    css盒子模型
    css选择器,背景样式,文本属性
  • 原文地址:https://www.cnblogs.com/163467wyj/p/13429684.html
Copyright © 2011-2022 走看看