时间复杂度O(n5)O(n5)。 code // Problem: D - Sum of SCC // Contest: AtCoder - AtCoder Regular Contest 163 // URL: https://atcoder.jp/contests/arc163/tasks/arc163_d // Memory Limit: 1024 MB // Time Limit: 2000 ms // // Powered by CP Editor (https://cpeditor.org) #inclu...
AtCoder Beginner Contest 163(D,E(区间dp),F(树上路径问题)),题目链接今天的题都很不错D-SumofLargeNumbers题意:求至少选k个数和的种类数。做法:刚开始感觉很难,涉及大数和、方案数。考虑k=2由于n+1个数是连续的,那我选最小的k个数求和:mi和最大的k个数求和:mx
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...
AtCoder Beginner Contest 163 (6/6) 比赛链接:Here AB水题, C - management 题意:给一棵\(N(2\le N\le2e5)\) 个节点的有根树,求每个节点的儿子数。 思路:由于输入直接给的是每个节点的父节点,直接计数即可。 const int N = 2e5 + 10; int a[N]; int main() { ios::sync_with_stdio(...
[AtCoder Beginner Contest 163] F path pass i (树型dfs,容斥定律) 链接:https://atcoder.jp/contests/abc163/tasks/abc163_f Problem Statement We have a tree with N
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...
代码 #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;
1. AtCoder Beginner Contest 162(3) 2. AtCoder Beginner Contest 168(2) 3. AtCoder Beginner Contest 164(2) 4. AtCoder Beginner Contest 157(2) 5. AtCoder Beginner Contest 166(1) 最新评论 1. Re: AtCoder Beginner Contest 166 努力,跟你的性别无关,跟你读不读大学的差距无关。买得...
定义dp[i][j]dp[i][j]代表当前放了i+ji+j个物品,其中ii个物品放在紧靠着左边,jj个物品放在紧靠着右边时产生的最大价值。 然后转移即可。 代码: #include<iostream>#include<cstdio>#include<cstring>#include<algorithm>#include<cmath>#include<queue>#include<stack>#include#include<set>#include<vector>#...
代码: #include<iostream> #define ll long long using namespace std; const ll mod=1e9+7; int main(){ ll N,K; ll ans=0; cin>>N>>K;//从[ 0 ~ N] 中选 ll sum=(1+N)*N/2;//总和 for(int i=K;i<=N;i++){//表示取 K 个数 //分别求出取 k 个数的最大值、与最小值 ...