A

B

题意:给你N个数(3e5) 每个数可以是0,a,b,a+b(3e5) 但是总数加起来要是定值K(18e10)

问总方法数mod 998244353

解:

把a+b的看成是一个a加上一个b的 这样从0-N枚举a的个数 判断b的个数是否合法

如果合法的话 这种情况的所有方法数就相当于在N个中选i个放a 然后再在N个中选剩下的b个放b

anser = (anser + (ncr(n, i) * ncr(n, remain / B) % mod)) % mod

/*Huyyt*/
#include<bits/stdc++.h>
#define mem(a,b) memset(a,b,sizeof(a))
#define pb push_back
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const int dir[][] = {{, }, {, }, {, -}, { -, }, {, }, {, -}, { -, -}, { -, }};
const int mod = , gakki = + + + + 1e9;
const int MAXN = 2e5 + , MAXM = 2e5 + , N = 3e5 + ;
int to[MAXM << ], nxt[MAXM << ], Head[MAXN], tot = ;
inline void addedge(int u, int v)
{
to[++tot] = v;
nxt[tot] = Head[u];
Head[u] = tot;
}
ll Qpow(ll a, ll b)
{
ll ans = , base = a;
while (b != )
{
if (b & != )
{
ans = (ans * base) % mod;
}
base = (base * base) % mod;
b >>= 1LL;
}
return ans % mod;
}
ll Inv(ll a)
{
return Qpow(a, mod - );
}
ll fact[N], Invfact[N], anser = ;
ll ncr(ll n, ll r)
{
if (r < || n < )
{
return ;
}
if (n < r)
{
return ;
}
ll a = fact[n];
a = (a * Invfact[r]) % mod;
a = (a * Invfact[n - r]) % mod;
return a;
}
int main()
{
ios_base::sync_with_stdio();
cin.tie();
ll n, A, B, K;
cin >> n >> A >> B >> K;
Invfact[] = Invfact[] = fact[] = fact[] = ;
for (ll i = ; i <= 3e5 + ; i++)
{
fact[i] = (fact[i - ] * i) % mod;
Invfact[i] = Inv(fact[i]);
}
ll remain;
for (ll i = ; i <= n; i++)
{
remain = K - i * A;
if (remain >= && remain % B == && remain / B <= n)
{
anser = (anser + (ncr(n, i) * ncr(n, remain / B) % mod)) % mod;
}
}
cout << anser << endl;
return ;
}

C

题意:给你一个数轴和N个线段 有两个人A,B A每次给B一个线段 要求B要走到线段的范围内 B初始在原点

A会选最优方案使得B走的距离最远 而B会选最优方案使得自己走的距离最少 问你最后B走的距离是多少

解:

A选的方案肯定是使得B在原点左右来回跑 这样使得跑的距离最大

这样我们把L从大到小排列 把R从小到大排列 如果有L>R 就说明B需要走这么长的距离来满足条件

/*Huyyt*/
#include<bits/stdc++.h>
#define mem(a,b) memset(a,b,sizeof(a))
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const int dir[][] = {{, }, {, }, {, -}, { -, }, {, }, {, -}, { -, -}, { -, }};
const int mod = , gakki = + + + + 1e9;
const int MAXN = 2e5 + , MAXM = 2e5 + , N = 1e5 + ;
int to[MAXM << ], nxt[MAXM << ], Head[MAXN], tot = ;
inline void addedge(int u, int v)
{
to[++tot] = v;
nxt[tot] = Head[u];
Head[u] = tot;
}
vector<int> l, r;
int main()
{
ios_base::sync_with_stdio();
cin.tie();
int n;
cin >> n;
l.push_back(), r.push_back();
for (int i = ; i <= n; i++)
{
int L, R;
cin >> L >> R;
l.push_back(L);
r.push_back(R);
}
ll anser = ;
sort(l.rbegin(), l.rend());
sort(r.begin(), r.end());
for (int i = ; i <= n; i++)
{
if (l[i] > r[i])
{
anser += 2LL * (l[i] - r[i]);
}
}
cout << anser << endl;
return ;
}

Atcoder grand 025 组合数学塔涂色 贪心走路博弈的更多相关文章

  1. Atcoder Grand Contest 010 C - Cleaning 树贪心(伪)

    C - Cleaning 题目连接: http://agc010.contest.atcoder.jp/tasks/agc010_c Description There is a tree with ...

  2. AtCoder Grand Contest 008

    AtCoder Grand Contest 008 A - Simple Calculator 翻译 有一个计算器,上面有一个显示按钮和两个其他的按钮.初始时,计算器上显示的数字是\(x\),现在想把 ...

  3. AtCoder Grand Contest 004

    AtCoder Grand Contest 004 A - Divide a Cuboid 翻译 给定一个\(A*B*C\)的立方体,现在要把它分成两个立方体,求出他们的最小体积差. 题解 如果有一条 ...

  4. AtCoder Grand Contest

    一句话题解 QwQ主要是因为这篇文章写的有点长……有时候要找某一个题可能不是很好找,所以写了这个东西. 具体的题意.题解和代码可以再往下翻._(:з」∠)_ AGC 001 C:枚举中点/中边. D: ...

  5. AtCoder Grand Contest 012

    AtCoder Grand Contest 012 A - AtCoder Group Contest 翻译 有\(3n\)个人,每一个人有一个强大值(看我的假翻译),每三个人可以分成一组,一组的强大 ...

  6. AtCoder Grand Contest 011

    AtCoder Grand Contest 011 upd:这篇咕了好久,前面几题是三周以前写的... AtCoder Grand Contest 011 A - Airport Bus 翻译 有\( ...

  7. AtCoder Grand Contest 009

    AtCoder Grand Contest 009 A - Multiple Array 翻译 见洛谷 题解 从后往前考虑. #include<iostream> #include< ...

  8. AtCoder Grand Contest 019 F-yes or no

    AtCoder Grand Contest 019 F-yes or no 解题思路: 考虑一个贪心策略,假设当前还有 \(x\) 道 \(\text{yes}\) 和 \(y\) 道 \(\text ...

  9. AtCoder Grand Contest 019 A: Ice Tea Store

    tourist出的题诶!想想就很高明,老年选手可能做不太动.不过A题还是按照惯例放水的. AtCoder Grand Contest 019 A: Ice Tea Store 题意:买0.25L,0. ...

随机推荐

  1. Java-Logger日志

    <转载于--https://www.cnblogs.com/yorickLi/p/6158405.html> Java中关于日志系统的API,在 java.util.logging 包中, ...

  2. Python_编程特色

    目录 目录 前言 软件环境 列表推导式 字典的默认值 forelse语句 交换两个变量的值 链式比较 真值测试 序列类型元素反转 连接字符串和列表 内置算术函数 利用zip来创建键值对 最后 前言 P ...

  3. Selenium 2自动化测试实战13(设置元素等待)

    一.设置元素等待 若在加载某个元素时延迟而造成的ElementNotVisbleException的情况出现,那么就会降低自动化脚本的稳定性,可以通过设置元素等待改善这种问题造成的不稳定. webdr ...

  4. 使用pthread下的mutex与cond_var模拟windows下的event几个接口

    两个版本的链接: https://github.com/neosmart/pevents https://github.com/moya-lang/Event 第一个版本能够模拟等待多个事件中的一个触 ...

  5. getApplication()和getApplicationContext()区别

    二者使用结果相同,我们写个代码分别打印二者返回结果,发现两个方法获取的是同一个对象. public class MainActivity extends Activity { @Override pr ...

  6. RTX修改标题logo方法

    摘要: 打开“腾讯通RTX管理器”→“配置向导”→“服务运行状态”→“停止所有服务”,退出“腾讯通RTX管理器”按照如下操作.①修改到期时间为:9999-12-300:0:0 用记事本打开“C:/Pr ...

  7. Salesforce学习之路-developer篇(五)一文读懂Aura原理及实战案例分析

    1. 什么是Lightning Component框架? Lightning Component框架是一个UI框架,用于为移动和台式设备开发Web应用程序.这是一个单页面Web应用框架,用于为Ligh ...

  8. js在页面中添加一个元素 —— 添加弹幕

    参考地址 [往下拉 —— 使用HTML DOM appendChild() 方法实现元素的添加 ] 一.创建 HTML <div class="right_liuyan"&g ...

  9. 微信小程序开发(一)----- 基础知识

    1.什么是微信小程序 概念:小程序是一种不需要下载安装即可使用的应用,它实现了应用“触手可及”的梦想,用户扫一扫或者搜一下即可打开应用,体现了“用完即走”的理念,用户不需要关心是否安装太多应用的问题, ...

  10. Linux系统基础知识整理(一)

    本文来自于: https://www.cnblogs.com/hafiz/p/6686187.html#4196989 一.说明 本篇文章,我将结合自己的实践以及简介,来对linux系统做一个直观清晰 ...