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. centos7 搭建测试环境

    1. 下载JDK8 地址:https://download.oracle.com/otn/java/jdk/8u221-b11/230deb18db3e4014bb8e3e8324f81b43/jdk ...

  2. Android Studio在Make Project时下载Grandle特别慢

    SDK下载完成了,建个工程, 又蒙了: Server returned HTTP response code: 502 for URL: https://services.gradle.org/dis ...

  3. MobileNets: Efficient Convolutional Neural Networks for Mobile Vision Applications

    1. 摘要 作者提出了一系列应用于移动和嵌入式视觉的称之为 MobileNets 的高效模型,这些模型采用深度可分离卷积来构建轻量级网络. 作者还引入了两个简单的全局超参数来有效地权衡时延和准确率,以 ...

  4. leetcode 72. 编辑距离

    /***** 定义状态: DP[i][j]其中i表示word1前i个字符,j表示Word2前i个字符 DP[i][j]表示单词1前i个字符匹配单词2前j个字符,最少变换次数: 状态转移: for i: ...

  5. Ruby小白入门笔记之<Rubymine工具的快捷键>

    智能快捷 Ctrl+Alt+G:弹出Generate Ctrl+Alt+L:格式化代码 Alt+F1:切换视图(Project, Structure, etc.). Alt+F2:弹出预览窗口,可选择 ...

  6. adb自动化农药金币

    本贴仅为记录贴 记录adb 的环境配置及python脚本的交互 1.adb 的下载 通过搜索adb工具即可下载,这里提供一个共享地址https://pan.baidu.com/s/103ix26tZy ...

  7. 阶段3 2.Spring_03.Spring的 IOC 和 DI_8 spring中bean的细节之生命周期

    区分单例还是多例对象 单例的几个状态 初始化方法和销毁方法 设置成我们定义的方法 测试 有创建和初始化.但是没有销毁,.对象一直没有销毁的方法 main方法是一切应用程序的入门.当main方法结束后. ...

  8. 1 Configuring SAP ERP Sales and Distribution -introduction to SAP

    SAP is one of the most popular enterprise resource planning (ERP) solutions inthe world. It offers a ...

  9. Unity3D中的SendMessage使用(消息传递的三种方法)

    概述 Unity提供的消息推送机制可以非常方便我们的脚本开发,它实现的是一种伪监听者模式,利用的是反射机制. 常用函数 关于消息推送,常用的函数有三个:”SendMessage“.”SendMessa ...

  10. debian 10 "Buster"正式发布了

    Debian Buster将从内核4.9.0.3升级到4.19.0-4.