/* HDU 6038 - Function [ 置换,构图 ] 题意: 给出两组排列 a[], b[] 问 满足 f(i) = b[f(a[i])] 的 f 的数目 分析: 假设 a[] = {2, 0, 1} 则 f(0) = b[f(2)] f(1) = b[f(0)] f(2) = b[f(1)] 即 f(0) = b[b[b[f(0)]]] f(1) = b[b[b[f(1)]]] f(2) = b[b[b[f(2)]]] 由于将 a[i]->i 连边可以得到不相交的多个循环 可以看出…
Function Time Limit: 4000/2000 MS (Java/Others)    Memory Limit: 131072/131072 K (Java/Others) Total Submission(s): 1610    Accepted Submission(s): 755 Problem Description You are given a permutation a from 0 to n−1 and a permutation b from 0 to m−1.…
/* HDU 6168 - Numbers [ 思维 ] | 2017 ZJUT Multi-University Training 9 题意: .... 分析: 全放入multiset 从小到大,慢慢筛 */ #include <bits/stdc++.h> using namespace std; const int N = 125250; int n, s[N]; int a[N], cnt; multiset<int> st; multiset<int>::it…
Function Time Limit: 4000/2000 MS (Java/Others)    Memory Limit: 131072/131072 K (Java/Others)Total Submission(s): 652    Accepted Submission(s): 267 Sample Input 3 2 1 0 2 0 1 3 4 2 0 1 0 2 3 1 Sample Output Case #1: 4 Case #2: 4 Source 2017 Multi-U…
Function Time Limit: 4000/2000 MS (Java/Others)    Memory Limit: 131072/131072 K (Java/Others)Total Submission(s): 1025    Accepted Submission(s): 457 Problem Description You are given a permutation a from 0 to n−1 and a permutation b from 0 to m−1.…
http://acm.hdu.edu.cn/showproblem.php?pid=6038 题意:给出两个序列,一个是0~n-1的排列a,另一个是0~m-1的排列b,现在求满足的f的个数. 思路: 先看一下样例吧: 对于这组数来说,假如我们先指定了f(0)对应的在b中的值,那么根据第2个式子,就可以得出f(1),根据f(1)就又可以得出f(2),最后根据f(2)就可以检验f(0)的值是否正确. 这也就是说,对于a中的一个循环节,只要确定了其中一个数所映射的值,那么其它数就都被相应的确定了. 所…
题目链接 Problem Description You are given a permutation a from 0 to n−1 and a permutation b from 0 to m−1. Define that the domain of function f is the set of integers from 0 to n−1, and the range of it is the set of integers from 0 to m−1. Please calcul…
/* HDU 6170 - Two strings [ DP ] | 2017 ZJUT Multi-University Training 9 题意: 定义*可以匹配任意长度,.可以匹配任意字符,问两串是否匹配 分析: dp[i][j] 代表B[i] 到 A[j]全部匹配 然后根据三种匹配类型分类讨论,可以从i推到i+1 复杂度O(n^2) */ #include <bits/stdc++.h> using namespace std; const int N = 2505; int t;…
/* HDU 6162 - Ch’s gift [ LCA,线段树 ] | 2017 ZJUT Multi-University Training 9 题意: N节点的树,Q组询问 每次询问s,t两节点之间的路径上点权值在[a,b]之间的点权总和 分析: 求出每个询问的LCA,然后离线 按dfs顺序更新树状数组,即某点处树状数组中存的值为其所有祖先节点的值 每个点处对答案的贡献为: 当其为第 i 个 lca 时, ans[i] -= 2 * query(a,b) , 再特判该节点 当其为第 i…
2017 Chinese Multi-University Training, BeihangU Contest Add More Zero 思路:log10(2^m) = m*log10(2) 代码: #pragma GCC optimize(2) #pragma GCC optimize(3) #pragma GCC optimize(4) #include<bits/stdc++.h> using namespace std; #define y1 y11 #define fi firs…