AtCoder Beginner Contest 163 题目链接D: 看样例+分析得知,假设现在要选ii个,那么能达到的最大的值就是sumi1=∑nx=n−i+1xsumi1=∑x=n−i+1nx, 最小值就是sumi2=∑i−1x=0xsumi2=∑x=0i−1x,那么每次可选择的数量就是sum1−sum2+1sum1−sum2+1,那么答案就为∑n+1i=k(sumi1...
constintmod =1e9+7;intans =0;voidadd(int&x,inty){ x += y;if(x >= mod) x -= mod;if(x <0) x += mod; }intcal(intl,intr){return1ll* (l + r) * (r - l +1) /2% mod; }intmain(){ ios::sync_with_stdio(false), cin.tie(nullptr);intn, k; cin >> n >> k;fo...
代码 #include<iostream>#include<math.h>#include<algorithm>usingnamespacestd;typedeflonglongLL;constintmod =1e9+7;LLadd(LL s,LL e, LL n)//这里需要写成long long,不然会炸{return(s+e)*n/2;//等差数列求和公式}intmain(){intn,k; cin>>n>>k; LL ans =1;//初始化为1,因为选n+1个数...
AtCoder Beginner Contest 163(D,E(区间dp),F(树上路径问题)),题目链接今天的题都很不错D-SumofLargeNumbers题意:求至少选k个数和的种类数。做法:刚开始感觉很难,涉及大数和、方案数。考虑k=2由于n+1个数是连续的,那我选最小的k个数求和:mi和最大的k个数求和:mx
[AtCoder Beginner Contest 163]F - path pass i(树型dfs,容斥定律) 链接:https://atcoder.jp/contests/abc163/tasks/abc163_f Problem Statement We have a tree with NN vertices numbered 11 to NN. The ii-th edge in this tree connects Vertex aiai and bibi. Additionally, each vertex is painted...
AtCoder Beginner Contest 163 比赛链接:https://atcoder.jp/contests/abc163/tasksA - Circle Pond题意由半径输出圆周长。代码#include <bits/stdc++.h> using namespace std; int main() { double r; cin >> r; cout << 2 * 3.14 * r; }B...
AtCoder Beginner Contest 163E - Active Infants(DP) Problem Statement There are NN children standing in a line from left to right. The activeness of the ii-th child from the left is AiAi. You can rearrange these children just one time in any order you like. ...
Atcoder beginner contest 163 f path pass i 传送门:https://atcoder.jp/contests/abc163/tasks/abc163_f 题目大意:一颗n个节点的树,每个节点有一个颜色。求对每一个颜色,至少经过一个该颜色节点的简单路径数量。 分析:虽然有O(n)的做法,但是这里还是贴一下虚树的做法。虚树的做法大概是:对每一种颜色建立...
AtCoder Regular Contest 163 发表于 2023-07-04 12:48阅读次数:112评论次数:2 摘要:# Preface 补题,这场比赛的时候被拉去开科研组会了,所以就没现场打了 这两天军训在伤病连划水,白天可以好好想题目舒服的一批 这场D题确实很妙,需要一些竞赛图相关的知识才能想到转化,不过也算是学到一个重要trick了吧 # ...
AtCoder Grand Contest 012 摘要:AtCoder Grand Contest 012 A AtCoder Group Contest 翻译 有3n3n个人,每一个人有一个强大值(看我的假翻译),每三个人可以分成一组,一组的强大值定义为三个人中第二强的人的强大值。求nn组最大的强大值之和。 题解 这。。。不是倒着选两个人,正着选一个 阅读全文 ...