Codeforces 832A. Sasha and Sticks】的更多相关文章

It's one more school day now. Sasha doesn't like classes and is always bored at them. So, each day he invents some game and plays in it alone or with friends. Today he invented one simple game to play with Lena, with whom he shares a desk. The rules…
A. Sasha and Sticks time limit per test2 seconds memory limit per test256 megabytes inputstandard input outputstandard output It's one more school day now. Sasha doesn't like classes and is always bored at them. So, each day he invents some game and…
Codeforces 1109D. Sasha and Interesting Fact from Graph Theory 解题思路: 这题我根本不会做,是周指导带飞我. 首先对于当前已经有 \(m\) 个联通块的有标号生成树的数量是 \[ n^{m-2}\prod_{i=1}^msize_i \] 其中 \(size_i\) 是第 \(i\) 个联通块的大小. 原理就是考虑 \(prufer\) 编码,先把每个联通块看成一个点,那么序列中每出现一个第 \(i\) 联通块缩成的点,能连的边的数…
It's one more school day now. Sasha doesn't like classes and is always bored at them. So, each day he invents some game and plays in it alone or with friends. Today he invented one simple game to play with Lena, with whom he shares a desk. The rules…
[Link]: [Description] [Solution] 傻逼题; 获取n/k; 对n/k的奇偶性讨论一下就好 [NumberOf WA] 0 [Reviw] [Code] #include <bits/stdc++.h> #define LL long long using namespace std; LL n,k; int main(){ //freopen("F:\\rush.txt","r",stdin); scanf("%l…
C. Lengthening Sticks time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output You are given three sticks with positive integer lengths of a, b, and c centimeters. You can increase length of some of…
Sasha and Interesting Fact from Graph Theory n 个 点形成 m 个有标号森林的方案数为 F(n, m) = m * n ^ {n - 1 - m} 然后就没啥难度了... #include<bits/stdc++.h> #define LL long long #define LD long double #define ull unsigned long long #define fi first #define se second #defin…
题目链接:http://codeforces.com/problemset/problem/471/A 题目数据规模1 - 9,可以用一个数组进行计数,减掉出现四次的数,看看还有几个是非零数,有一个就是大象,有两个就是北极熊:如果没有四个数的,那就是Alien. AC代码: #include <cstdio> using namespace std; int cnt[10]; int x, id; int main() { id = 0; cnt[10] = {0}; for (int i =…
题目链接:http://codeforces.com/contest/572/problem/C 题意:给出a,b,c,l要求a+x,b+y,c+z构成三角形,x+y+z<=l,成立的x,y,z有多少种 题解:看上去感觉挺复杂的其实就是简单枚举一下就行,首先要知道可以将总的取法减去不满足的取法就可以得到答案, 当然也可以直接枚举可行的方案但是会很复杂.所以最好采用减的方案. 总的方案的求法:就是将l分成3份,显然分法有C(i+2)取(2). 然后再分别减去以a,b,c为最长边不符合条件的种类即可…
Codeforces 题面传送门 & 洛谷题面传送门 讲个笑话,这题是 2020.10.13 dxm 讲题时的一道例题,而我刚好在一年后的今天,也就是 2021.10.13 学 LCT 时做到了这道题...... 首先考虑一个区间的导出子图是一棵树的充要条件.显然这些点组成的边集不能有环,其次这些点组成的导出子图必须满足 \(|V|-|E|=1\),而对于一个不存在环的图必然有 \(|V|-|E|\ge 1\),因此这两个条件加在一起就组成了一个区间符合条件的充要条件. 考虑如何维护之,注意到当…