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. 获取手机本地IP地址

    public String getLocalIpAddress() { try { for (Enumeration<NetworkInterface> en = NetworkInter ...

  2. 谈一谈 Android 的安全机制?

    1.Android 是基于 Linux 内核的,因此 Linux 对文件权限的控制同样适用于 Android,在 Android 中每个应用都有自己的/data/data/包名 文件夹,该文件夹只能该 ...

  3. ControlTemplate in WPF —— Expander

    <ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" x ...

  4. redis源码分析之数据结构--dictionary

    本文不讲hash算法,而主要是分析redis中的dict数据结构的特性--分步rehash. 首先看下数据结构:dict代表数据字典,每个数据字典有两个哈希表dictht,哈希表采用链式存储. typ ...

  5. 调整Linux终端显示分辨率

    linux 默认cli (command line interface)分辨率一般都比较小,显示的字体很大,不太美观,有时还影响结果的显示(例如出现kernel panic).所以有必要改变一下cli ...

  6. Jenkins pipeline+Maven+Gitlab

    参照文档:http://www.cnblogs.com/xiaodai12138/p/9996995.html

  7. activiti随笔记录

    核心组件介绍 关键对象 1.      Deployment:流程部署对象,部署一个流程时创建. 2.      ProcessDefinitions:流程定义,部署成功后自动创建. 3.       ...

  8. mysql双主双从技术

    一.准备环境 [root@localhost ~]# vim /etc/hosts 192.168.40.154 master1     192.168.40.129 master2          ...

  9. vue --- vscode 配置 .vue文件生成结构

    1.选择“文件 -> 首选项 -> 用户代码片段”,此时,会弹出一个搜索框,输入vue      选择vue后,编辑器会自动打开一个名字为vue.json的文件 2.复制以下内容到这个文件 ...

  10. 小记---------FLUM的三种配置方式:spooldir、exec、hadoop sink

    FLUM概述     是一个分布式的数据收集系统,具有高可靠.高可用.事务管理.失败重启等功能,数据处理速度快,完全可以用于生产环境   核心:agent(是FLUM的一个代号,名字    ).age ...