题目链接 题意:给你两个数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 …
C. Rumor time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output Vova promised himself that he would never play computer games... But recently Firestorm — a well-known game developing company — pu…
B. Beautiful Divisors time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output Recently Luba learned about a special kind of numbers that she calls beautiful numbers. The number is called beautiful…
A. Chess For Three time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Alex, Bob and Carl will soon participate in a team chess tournament. Since they are all in the same team, they have decide…
A. Chess For Three time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Alex, Bob and Carl will soon participate in a team chess tournament. Since they are all in the same team, they have decide…
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…