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(1≤t≤103), the number of testcases.

For each testcase, the first line contains four integers a,b,c,d(0≤a,b,c,d≤107,a+b+c+d≥1).

 
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;
}

  

 
 

杭电多校第九场 hdu6425 Rikka with Badminton 组合数学 思维的更多相关文章

  1. 杭电多校第九场 hdu6424 Rikka with Time Complexity 数学

    Rikka with Time Complexity Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 524288/524288 K ( ...

  2. 杭电多校第九场 HDU6415 Rikka with Nash Equilibrium dp

    Rikka with Nash Equilibrium Time Limit: 10000/5000 MS (Java/Others)    Memory Limit: 524288/524288 K ...

  3. 杭电多校第九场 D Rikka with Stone-Paper-Scissors 数学

    Rikka with Stone-Paper-Scissors Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 524288/52428 ...

  4. 2018 Multi-University Training Contest 9 杭电多校第九场 (有坑待补)

    咕咕咕了太久  多校博客直接从第三场跳到了第九场orz 见谅见谅(会补的!) 明明最后看下来是dp场 但是硬生生被我们做成了组合数专场…… 听说jls把我们用组合数做的题都用dp来了遍 这里只放了用组 ...

  5. Rikka with Game[技巧]----2019 杭电多校第九场:1005

      Rikka with Game Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 524288/524288 K (Java/Othe ...

  6. Rikka with Travels(2019年杭电多校第九场07题+HDU6686+树形dp)

    目录 题目链接 题意 思路 代码 题目链接 传送门 题意 定义\(L(a,b)\)为结点\(a\)到结点\(b\)的路径上的结点数,问有种\(pair(L(a,b),L(c,d))\)取值,其中结点\ ...

  7. 2019杭电多校第⑨场B Rikka with Cake (主席树,离散化)

    题意: 给定一块n*m的矩形区域,在区域内有若干点,每个顶点发出一条射线,有上下左右四个方向,问矩形被分成了几个区域? 思路: 稍加观察和枚举可以发现,区域数量=射线交点数+1(可以用欧拉定理验证,但 ...

  8. 2018 Multi-University Training Contest 1 杭电多校第一场

    抱着可能杭电的多校1比牛客的多校1更恐怖的想法 看到三道签到题 幸福的都快哭出来了好吗 1001  Maximum Multiple(hdoj 6298) 链接:http://acm.hdu.edu. ...

  9. 2018 Multi-University Training Contest 2 杭电多校第二场

    开始逐渐习惯被多校虐orz  菜是原罪 1004  Game    (hdoj 6312) 链接:http://acm.hdu.edu.cn/showproblem.php?pid=6312 虽然披着 ...

随机推荐

  1. 【iOS】Xcode 插件安装后无效

    今天把 Xcode 升级到 7.3.1,发现插件安装后无效…… 原因:苹果要求加入UUID证书从而保证插件的稳定性. 解决方法: 1. 查看Xcode的UUID 在终端输入以下命令: defaults ...

  2. 二进制文件安装k8s所需要的证书服务

    利用二进制文件安装etcd所需要的证书服务 CFSSL是CloudFlare开源的一款PKI/TLS工具. CFSSL 包含一个命令行工具 和一个用于 签名,验证并且捆绑TLS证书的 HTTP API ...

  3. codeforces 340 A. The Wall

    水水的一道题,只需要找xy的最小公倍数,然后找a b区间有多少个可以被xy的最小公倍数整除的数,就是答案. //============================================ ...

  4. 1、大型项目的接口自动化实践记录--robotframework环境搭建

    因为人力.团队技术问题,选用robotframework来做自动化,首先说下环境搭建 齐涛道长的入门教程非常棒:http://blog.csdn.net/tulituqi/article/detail ...

  5. 又拍云叶靖:OpenResty 在又拍云存储中的应用

    2019 年 7 月 6 日,OpenResty 社区联合又拍云,举办 OpenResty × Open Talk 全国巡回沙龙·上海站,又拍云平台开发部负责人叶靖在活动上做了<OpenRest ...

  6. Scala集合(四)

    1. 集合 集合主要有三种: Sequence Map Set sequence是一种线性元素的集合,可能会是索引或者线性的(链表).map是包含键值对的集合,就像Java的Map,set是包含无重复 ...

  7. if IE语句 | 判断浏览器IE版本及添加升级提示

    本文引自:http://blog.csdn.net/u013372487/article/details/48521929 实现方法 判断当前浏览器是否IE6(或IE6内核) <!--[if I ...

  8. 全球十大OTA 谁能有一席之地?

    全球十大OTA 谁能有一席之地? http://www.traveldaily.cn/article/78381/1 2014-03-05 来源:i黑马 随着旅游行业日新月异的发展,在线旅游网站的出现 ...

  9. struts的上传下载

    文件上传 添加jar包 commons-io-1.3.2.jar commons-fileupload-1.2.1.jar 前台页面 form表单 method值为post 添加"encty ...

  10. 带你剖析WebGis的世界奥秘----点和线的世界

    前言 昨天写了好久的博文我没保存,今天在来想继续写居然没了,气死人啊这种情况你们见到过没,所以今天重新写,我还是切换到了HTML格式的书写上.废话不多说了,我们现在就进入主题,上周我仔细研究了WebG ...