D. Credit Card Recenlty Luba got a credit card and started to use it. Let's consider n consecutive days Luba uses the card. She starts with 0 money on her account. In the evening of i-th day a transaction ai occurs. If ai > 0, then ai bourles are dep…
C. Rumor Vova promised himself that he would never play computer games... But recently Firestorm — a well-known game developing company — published their newest game, World of Farcraft, and it became really popular. Of course, Vova started playing it…
B. Beautiful Divisors Recently Luba learned about a special kind of numbers that she calls beautiful numbers. The number is called beautiful iff its binary representation consists of k + 1 consecutive ones, and then k consecutive zeroes. Some example…
A. Chess For Three Alex, Bob and Carl will soon participate in a team chess tournament. Since they are all in the same team, they have decided to practise really hard before the tournament. But it's a bit difficult for them because chess is a game fo…
连边的点用并查集检查是否有环,如果他们的fa是同一个点说明绕了一圈绕回去了.n个点一共能连n-1条边,如果小于n-1条边说明存在多个联通块. #define HAVE_STRUCT_TIMESPEC #include<bits/stdc++.h> using namespace std; ],b[]; ]; ]; ]; int find_(int x){ if(fa[x]==x) return x; return fa[x]=find_(fa[x]); } set<int>st;…
题目链接 题意:给你两个数x,yx,yx,y,让你构造一些长为yyy的数列,让这个数列的累乘为xxx,输出方案数. 思路:考虑对xxx进行质因数分解,设某个质因子PiP_iPi​的的幂为kkk,则这个质因子的贡献就相当于把kkk个PiP_iPi​放到yyy个盒子中,且盒子可能为空,方案为C(k+y−1,y)C(k+y-1,y)C(k+y−1,y),然后每个质因子的方案乘在一起即可.最后,因为负号也会出现,但xxx为正,所以就是在yyy个位置上选偶数个位置放负号,方案为2y−12^{y-1}2y−…
题意 给定一棵 \(n\) 个点的带点权树,以 \(1\) 为根, \(m\) 次询问,每次询问给出两个值 \(p, k\) ,求以下值: \(p\) 的子树中距离 \(p \le k\) 的所有点权最小值,询问强制在线. \(n \le 10^5 , m \le 10^6, TL = 6s\) 题解 如果不强制在线,直接线段树合并就做完了. 强制在线,不难想到用一些可持久化的结构来维护这些东西. 其实可以类似线段树合并那样考虑,也就是说每次合并的时候我们依然使用儿子的信息. 只要在合并 \(x…
A.每个状态只有一种后续转移,判断每次转移是否都合法即可. #include <iostream> #include <cstdio> using namespace std; ], n; bool check(int x){ ] == x) return false; ], r = x, s = -a[]-x; ; i <= n; i++){ if(a[i] == s) return false; l = a[i]; r = s; s = -l-r; } return tr…
总的来说这套题还是很不错的,让我对主席树有了更深的了解 A:水题,模拟即可 #include<bits/stdc++.h> #define fi first #define se second #define mp make_pair #define pb push_back #define pi acos(-1.0) #define ll long long #define mod 1000000007 #define C 0.5772156649 #define ls l,m,rt<…
D. Credit Card time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output Recenlty Luba got a credit card and started to use it. Let's consider n consecutive days Luba uses the card. She starts with …