• 杭电多校第九场 hdu6425 Rikka with Badminton 组合数学 思维


    Rikka with Badminton

    Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 524288/524288 K (Java/Others)
    Total Submission(s): 351    Accepted Submission(s): 219


    Problem Description
    In the last semester, Rikka joined the badminton club.

    There are n students in the badminton club, some of them have rackets, and some of them have balls. Formally, there are a students have neither rackets nor balls, bstudents have only rackets, c students have only balls, and d students have both rackets and balls. (a+b+c+d=n)

    This week, the club is going to organize students to play badminton. Each student can choose to take part in or not freely. So there are 2n possible registration status.

    To play badminton, there must be at least two students who have rackets and at least one students who have balls. So if there aren't enough balls or rackets, the activity will fail. 

    Now, Rikka wants to calculate the number of the status among all 2n possible registration status which will make the activity fail.
     
    Input
    The first line contains a single number t(1t103), the number of testcases.

    For each testcase, the first line contains four integers a,b,c,d(0a,b,c,d107,a+b+c+d1).
     
    Output
    For each testcase, output a single line with a single integer, the answer modulo 998244353.
     
    Sample Input
    3 1 1 1 1 2 2 2 2 3 4 5 6
     
    Sample Output
    12 84 2904
     
    Source
     
    Recommend
    chendu   |   We have carefully selected several similar problems for you:  6425 6424 6423 6422 6421 
     
    题意:没有球没有拍,有拍,有球,有拍又有球的人分别为a,b,c,d,每个人都可以参加比赛,组织一场比赛至少要两个球拍和一个球,问不能组织成功比赛的可能性?
    分析:不能成功组织比赛的情况为:
      不考虑d:只有拍:2^a*2^b
            可能有拍和球:2^a*2^c*(1+b)
            减去重复的情况没有拍:2^a
      考虑d:只能有一个d:2^a*2^c*d
      所以总的不重复情况:2^a*2^b+2^a+2^a*2^c*d-2^a*2^c*(1+b)
    参考博客:https://blog.csdn.net/qq_41037114/article/details/81876518
    AC代码:
    #include <map>
    #include <set>
    #include <stack>
    #include <cmath>
    #include <queue>
    #include <cstdio>
    #include <vector>
    #include <string>
    #include <bitset>
    #include <cstring>
    #include <iomanip>
    #include <iostream>
    #include <algorithm>
    #define ls (r<<1)
    #define rs (r<<1|1)
    #define debug(a) cout << #a << " " << a << endl
    using namespace std;
    typedef long long ll;
    const ll maxn = 1e6+10;
    const ll mod = 998244353;
    const double pi = acos(-1.0);
    const double eps = 1e-8;
    ll qow( ll a, ll b ) {
        ll ans = 1;
        while(b) {
            if(b&1) {
                ans = ans*a%mod;
            }
            a = a*a%mod;
            b /= 2;
        }
        return ans;
    }
    int main() {
        ios::sync_with_stdio(0);
        ll T;
        cin >> T;
        while( T -- ) {
            ll a, b, c, d;
            cin >> a >> b >> c >> d;
            ll ans = qow(2,a)*qow(2,b)%mod;
            ans = (ans+((qow(2,a+c)-qow(2,a)+mod)%mod*(1+b))%mod)%mod;
            ans = (ans+qow(2,a+c)*d)%mod;
            cout << ans << endl;
        }
    
        return 0;
    }
    

      

     
     
    彼时当年少,莫负好时光。
  • 相关阅读:
    keepalived.conf配置说明
    监控端口是否开放,端口未开放关闭虚拟ip,端口开放启动虚拟IP
    lvs UDP端口负载均衡配置
    keepalived自动安装脚本
    Keepalived+LVS实现高可用负载均衡双主模式
    cookie和session的区别
    jmeter 关联
    浏览器缓存详解:expires,cache-control,last-modified,etag详细说明
    Session、Cookie、Cache、Token分别是什么及区别
    获取MyBatis
  • 原文地址:https://www.cnblogs.com/l609929321/p/9512678.html
Copyright © 2020-2023  润新知