杭电多校第九场 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
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.
For each testcase, the first line contains four integers a,b,c,d(0≤a,b,c,d≤107,a+b+c+d≥1).
1 1 1 1
2 2 2 2
3 4 5 6
84
2904
#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 组合数学 思维的更多相关文章
- 杭电多校第九场 hdu6424 Rikka with Time Complexity 数学
Rikka with Time Complexity Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 524288/524288 K ( ...
- 杭电多校第九场 HDU6415 Rikka with Nash Equilibrium dp
Rikka with Nash Equilibrium Time Limit: 10000/5000 MS (Java/Others) Memory Limit: 524288/524288 K ...
- 杭电多校第九场 D Rikka with Stone-Paper-Scissors 数学
Rikka with Stone-Paper-Scissors Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 524288/52428 ...
- 2018 Multi-University Training Contest 9 杭电多校第九场 (有坑待补)
咕咕咕了太久 多校博客直接从第三场跳到了第九场orz 见谅见谅(会补的!) 明明最后看下来是dp场 但是硬生生被我们做成了组合数专场…… 听说jls把我们用组合数做的题都用dp来了遍 这里只放了用组 ...
- Rikka with Game[技巧]----2019 杭电多校第九场:1005
Rikka with Game Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 524288/524288 K (Java/Othe ...
- Rikka with Travels(2019年杭电多校第九场07题+HDU6686+树形dp)
目录 题目链接 题意 思路 代码 题目链接 传送门 题意 定义\(L(a,b)\)为结点\(a\)到结点\(b\)的路径上的结点数,问有种\(pair(L(a,b),L(c,d))\)取值,其中结点\ ...
- 2019杭电多校第⑨场B Rikka with Cake (主席树,离散化)
题意: 给定一块n*m的矩形区域,在区域内有若干点,每个顶点发出一条射线,有上下左右四个方向,问矩形被分成了几个区域? 思路: 稍加观察和枚举可以发现,区域数量=射线交点数+1(可以用欧拉定理验证,但 ...
- 2018 Multi-University Training Contest 1 杭电多校第一场
抱着可能杭电的多校1比牛客的多校1更恐怖的想法 看到三道签到题 幸福的都快哭出来了好吗 1001 Maximum Multiple(hdoj 6298) 链接:http://acm.hdu.edu. ...
- 2018 Multi-University Training Contest 2 杭电多校第二场
开始逐渐习惯被多校虐orz 菜是原罪 1004 Game (hdoj 6312) 链接:http://acm.hdu.edu.cn/showproblem.php?pid=6312 虽然披着 ...
随机推荐
- netty使用EmbeddedChannel对channel的出入站进行单元测试
一种特殊的Channel实现----EmbeddedChannel,它是Netty专门为改进针对ChannelHandler的单元测试而提供的. 名称 职责 writeInbound 将入站消息写到E ...
- __int64与long long、long的区别
首先来看一看int.long.long long的取值范围 int 所占字节数为:4 表示范围为:-2147483648~2147 ...
- 【Laravel】 安装及常用的artisan命令
composer Laravel 安装 cmd composer create-project laravel/laravel Laravel5 之后自动创建 常用的artisan命令 全局篇 查看a ...
- 记一次python时间格式转换遇到的坑
需求:拿到指定格式的时间的前一天的时间,如果今天是月初,年初,自动转换,比如:输入时间是:2019-06-27 23:59:59输出时间是:2019-06-26 23:59:59 之前用datetim ...
- 数据结构之堆栈C++版
/* 堆栈本身就是一种线性数据结构,说白了他与容器线性表是一种数据类型,不要认为他多高大上. 实时上他还没有线性表复杂,下面简单的实现一下堆栈. 事实上整个核心操作都是在操作指向堆栈的顶部元素的指针 ...
- Of efficiency and methodology
There are only too many articles and books which pertains to the discussion of efficiency and method ...
- Spark 系列(十)—— Spark SQL 外部数据源
一.简介 1.1 多数据源支持 Spark 支持以下六个核心数据源,同时 Spark 社区还提供了多达上百种数据源的读取方式,能够满足绝大部分使用场景. CSV JSON Parquet ORC JD ...
- web 上读取图片,并转化为指定格式
一. 转换为 base64 public static string ObtainBase64FromWeb(string domain, string path) { string url = &q ...
- 如何在GitHub上上传自己本地的项目?(很适合新手使用哦!)
这是我看了一些大佬们的博客后,尝试了几次,终于成功了上传项目,所以想做一下总结,以便以后查看,同时想分享给才接触GitHub的新手们,希望能够有所帮助~ 条条大路通罗马,上传的方法肯定不止一种,等我学 ...
- rwcheck:为嵌入式设备设计的读写压测工具
我设计的一款读写压测工具,开源在我的github仓库 rwcheck是一个对嵌入式设备进行读写压测的工具 什么是rwcheck 正如其名,rwcheck工具用于读写压测.它是什么工作原理呢?为什么要用 ...