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. ERROR 临时

    ERROR ITMS-4238: "Redundant Binary Upload. There already exists a binary upload with build vers ...

  2. ubuntu 下常用的mysql 命令

    一.mysql服务操作  0.查看数据库版本 sql-> status;  1.net start mysql //启动mysql服务  2.net stop mysql //停止mysql服务 ...

  3. 技巧:结合Zabbix与SNMP监控嵌入式设备

    在如何利用Zabbix监控网络设备三篇文章的前两篇中,我们介绍了如何通过Zabbix代理监控网络设备.但有些设备无法安装Zabbix代理,需要采用其他方法监控.需要考虑无法安装软件的嵌入式设备或应用程 ...

  4. L1005矩阵取数游戏

    #include <bits/stdc++.h> using namespace std; typedef long long ll; #define rep(i, a, b) for ( ...

  5. DataPipeline丨DataOps的组织架构与挑战

    作者:DataPipeline CEO 陈诚 前两周,我们分别探讨了“数据的资产负债表与现状”及“DataOps理念与设计原则”.接下来,本文会在前两篇文章的基础上继续探讨由DataOps设计原则衍生 ...

  6. JVM(十一):内存分配

    JVM(十一):内存分配 在前面的章节中,我们花了大量的篇幅去介绍 JVM 内的内存布局.对象在内存中的状态.垃圾回收的算法和具体实现等.今天让我们探讨一下对象是如何分配内存的. 堆内存划分 前面说过 ...

  7. 如何利用jenkins插件查看allure报告-----完整篇(解决404和无数据问题)

    背景: python3+appium+pytest+allure写了安卓的自动化脚本,在windows本机pycharm上跑通过后生成了allure报告.  公司jenkins搭建在linux服务器上 ...

  8. mysql数据库磁盘空间被撑爆,创建定时任务定期释放资源

    问题描述: 这是我在工作中遇到的一个问题,目前只发现mysql数据库存在该问题,Oracle和gaussDB未发现磁盘空间被占满的情况,部署堆栈服务的时候抛出了写入数据库表失败的问题,经排查,在数据库 ...

  9. Spring框架完全掌握(下)

    接着上一篇文章的内容Spring框架完全掌握(上),我们继续深入了解Spring框架. Spring_AOP 考虑到AOP在Spring中是非常重要的,很有必要拿出来单独说一说.所以本篇文章基本上讲述 ...

  10. Redis|Sentinel 高可用架构

    一 前言 Redis-Sentinel是Redis官方推荐的高可用性(HA)解决方案,当用Redis做Master-slave的高可用方案时,假如master宕机了,Redis本身(包括它的很多客户端 ...