zoukankan      html  css  js  c++  java
  • 杭电多校第九场 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;
    }
    

      

     
     
    彼时当年少,莫负好时光。
  • 相关阅读:
    前缀和与差分
    可行!解决bitmap缩放失真问题
    Android 中的 File renameTo() 使用
    XMPP 中客户端断线及网络异常处理
    webview 离线缓存,html5游戏适用
    Mac os x下配置 Android ndk 开发环境
    从外企到国企的工作环境改变
    微软SQL Server数据库SQL语句导入导出大全,包括与其他数据库和文件的数据的导入导出
    人生第一职业:我当了人民教师
    JOIN 分为内连接,外连接(左外连接,右外连接,全外连接)
  • 原文地址:https://www.cnblogs.com/l609929321/p/9512678.html
Copyright © 2011-2022 走看看