血崩- - /* CodeForces 839B - Game of the Rows [ 贪心,分类讨论] | Codeforces Round #428 (Div. 2) 注意 2 7 2 2 2 2 2 2 2 这组- - */ #include <bits/stdc++.h> using namespace std; int n, n2, n4, a[105], k; bool solve() { n2 = 2*k; n4 = k; for (int i = 1; i <= n;…
起初误以为到每个叶子的概率一样于是.... /* CodeForces 839C - Journey [ DFS,期望 ] | Codeforces Round #428 (Div. 2) */ #include <bits/stdc++.h> using namespace std; const int N = 100005; int n; vector<int> G[N]; double dp[N], val[N]; bool vis[N]; void dfs(int u, i…
赛后听 Forever97 讲的思路,强的一匹- - /* CodeForces 839D - Winter is here [ 数论,容斥 ] | Codeforces Round #428 (Div. 2) 题意: 给出数列a[N] 对每个子集,若 gcd(a[I1], a[I2], a[I3] ..., a[In]) > 1,则贡献为 n*gcd 求总贡献和 限制: N <= 2e5,a[i] <= 1e6 分析: 记录 num[i]数组为 i 的倍数的个数 则 gcd >=…
839B - Game of the Rows 思路:先放4个的,然后再放2个的,最后再放1个的. 代码: #include<bits/stdc++.h> using namespace std; #define ll long long #define pb push_back #define mem(a,b) memset((a),(b),sizeof(a)) ]; int main() { int n,k; cin>>n>>k; ; int c4=n; ;i<…
Daenerys Targaryen has an army consisting of k groups of soldiers, the i-th group contains ai soldiers. She wants to bring her army to the other side of the sea to get the Iron Throne. She has recently bought an airplane to carry her army through the…
B. Game of the Rows time limit per test:1 second memory limit per test:256 megabytes input:standard input output:standard output Daenerys Targaryen has an army consisting of k groups of soldiers, the i-th group contains ai soldiers. She wants to brin…
[Link]:http://codeforces.com/contest/839/problem/B [Description] 给你n排的如题目所示的位置; 同一排中(1,2) 算相邻; (3,4),(4,5),(5,6)算相邻,然后(7,8)算相邻; 这里的(x,y)表示某个人坐在x,另外一个人坐在y的话. 问你够不够安排k组的人; 使得相邻座位的人都是相同组的人; 是则输出YES-. [Solution] 中间的那4个位置; 是没办法用来放不同组的成对的. 也即 xxyy不能放在中间那4个…
题目链接:http://codeforces.com/contest/839 A. Arya and Bran 题意:每天给你一点糖果,如果大于8个,就只能给8个,剩下的可以存起来,小于8个就可以全部给完 解法:水题,按照题意模拟一下即可. #include <bits/stdc++.h> using namespace std; int n, k, a[110]; int main() { cin>>n>>k; int s = 0; for(int i=1; i<…
D. Winter is here 题目连接: http://codeforces.com/contest/839/problem/D Description Winter is here at the North and the White Walkers are close. John Snow has an army consisting of n soldiers. While the rest of the world is fighting for the Iron Throne,…
http://codeforces.com/contest/839/problem/E 最大团裸题= =,用Bron–Kerbosch算法,复杂度大多博客上没有,维基上查了查大约是O(3n/3) 最大团: V中取K个顶点,两点间相互连接 最大独立集: V中取K个顶点,两点间不连接 最大团数量 = 补图中最大独立集数 //#pragma comment(linker, "/stack:200000000") //#pragma GCC optimize("Ofast,no-st…