代码: #include<cstdio> #include<cstring> #include<set> using namespace std; int vis[10]; int dp[100005]; int main() { dp[0]=0; for(int i=1;i<=100005;i++) { memset(vis,0,sizeof(vis)); int x=i; int flag=0; while(x) { int r=x%10; if(vis[r]…
由于每个元素贡献是线性的,那么等价于求每个元素出现在多少个异或和为$0$的子集内.因为是任意元素可以去异或,那么自然想到线性基.先对整个集合A求一遍线性基,设为$R$,假设$R$中元素个数为$r$,那么任取一个不在$R$内的元素,$R$中肯定存在一种取法能和这个元素异或和为$0$.同理,取定一个不在$R$内的元素,再随便取另外任意个不在$R$内的元素,$R$内仍然存在一种取法使得这个异或和为$0$.那么每个不在$R$内的元素包含在$2^{n - r - 1}$个集合内(其他不在$R$内的元素可以…
http://acm.hdu.edu.cn/showproblem.php?pid=5791 HDU5791 Two 题意 :两个数组,多少个不连续子串相等 思路: dp[i][j] :a串i结尾,b串j结尾的不连续子串数目个数 #include<cstdio> #include<cstring> #include<algorithm> #include<iostream> using namespace std; typedef long long ll;…
Expression Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others)Total Submission(s): 175 Accepted Submission(s): 95 Problem Description Teacher Mai has n numbers $a_1,a_2,\dots,a_n$ and $n-1$ operators ("+","…
Bombing plan Time Limit: 8000/4000 MS (Java/Others) Memory Limit: 262144/262144 K (Java/Others)Total Submission(s): 416 Accepted Submission(s): 96 Problem Description Kingdom Y is in the war with kingdom X. Kingdom X consists of N cities,there…
2019 Multi-University Training Contest 7 A. A + B = C 题意 给出 \(a,b,c\) 解方程 \(a10^x+b10^y=c10^z\). trick hash! B.Bracket Sequences on Tree unsolved 做法 树hash,统计答案 然后疯狂wa,直到特判了最后两组数据... 假的AC F. Final Exam upsolved 题意 参加考试,确保通过 \(k\) 道题目. 复盘 先是认定了,所有题都复习相…
2019 Multi-University Training Contest 2 A. Another Chess Problem B. Beauty Of Unimodal Sequence 题意 给一个序列,求下标字典序最小和字典序最大的,先增后减的序列. 解体过程 比赛时首先不知道字典序最小LIS怎么求. 试图枚举分界点.[解体的开始] 公无渡河,公竟渡河? 活鱼在摸鱼,rdc在划水,sdcgvhgj在水深火热. 做法 考虑字典序最小的LIS怎么求? 这是个经典问题,预处理前缀LIS后缀L…
2019 Multi-University Training Contest 5 http://acm.hdu.edu.cn/contests/contest_show.php?cid=852 1004. Equation 把所有绝对值的零点排个序,然后解方程就好了. #include<bits/stdc++.h> using namespace std; // #define int long long void read(int &x) { x=0;int f=1;char ch=…
2019 Multi-University Training Contest 3 http://acm.hdu.edu.cn/contests/contest_show.php?cid=850 1004. Distribution of books 考虑二分答案,设当前二分出来的是\(x\). 设\(f_i\)表示前\(i\)个能分成最多的段数,使得每一段和都\(\leqslant x\). 转移显然,枚举一个\(j\),若\(s_i-s_j\leqslant x\)则转移,\(s_i\)表示前…
2019 Multi-University Training Contest 2 http://acm.hdu.edu.cn/contests/contest_show.php?cid=849 1005. Everything Is Generated In Equal Probability 考虑一个随机的排列的逆序对个数,显然对于两个数\(a,b\),他们位置是均匀排布的,也就是说有\(\frac{1}{2}\)的概率成为逆序对,并且是独立的. 所以一个长度为\(n\)的随机排列期望逆序对个…
题目:http://acm.hdu.edu.cn/showproblem.php?pid=6582 Path Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 262144/262144 K (Java/Others)Total Submission(s): 3747 Accepted Submission(s): 1075 Problem Description Years later, Jerry fell in love…
Welcome Party Time Limit: 4000/4000 MS (Java/Others) Memory Limit: 524288/524288 K (Java/Others)Total Submission(s): 875 Accepted Submission(s): 194 Problem Description The annual welcome party of the Department of Computer Science and Technolo…
Big binary tree Time Limit: 4000/2000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others)Total Submission(s): 597 Accepted Submission(s): 207 Problem Description You are given a complete binary tree with n nodes. The root node is numbere…
Add More Zero Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 131072/131072 K (Java/Others)Total Submission(s): 398 Accepted Submission(s): 283 Sample Input 1 64 Sample Output Case #1: 0 Case #2: 19 Source 2017 Multi-University Trainin…