Little W and Contest 思路:首先很显然是并查集去维护答案。 一开始,所有点都是独立的。那么设CF1 = 1的总个数。CF2 = 2的总个数 那么一开始ans = C(CF1,1)*C(CF2,2)+C(CF2,3). 那么考虑合并后怎么维护答案。 这里运用了容斥思想。 当我们合并 ...
分类:
其他好文 时间:
2020-07-29 10:20:09
阅读次数:
65
Motivation The task of finding nearest neighbours is very common. You can think of applications like finding duplicate or similar documents, audio/vid ...
分类:
其他好文 时间:
2020-07-29 10:07:50
阅读次数:
68
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=6797 题目大意:n个点的完全图,要求删k条边,求删完k条边后的最短路的最大值。 3≤n≤50,1≤k≤min(n?2,5) 边权为[ 1 , 10^4 ] 的随机数 题解: 删的边一定在当前的最短路上, ...
分类:
Web程序 时间:
2020-07-29 09:55:43
阅读次数:
145
A. Common Prefixes 题目链接 代码: #include<bits/stdc++.h> using namespace std; const int maxn = 1e6 + 10; #define ll long long #define ios std::ios::sync_wi ...
分类:
其他好文 时间:
2020-07-29 09:52:41
阅读次数:
58
HDU 6608 题意:给以你一个质数,求小于它的最大质数的阶乘。 分析:Miller-Rabin快速判断素性,找到这个最大素数。此外,加上威尔逊定理推式子就好了。威尔逊定理描述的内容是对于一个正素数p: ? \((k-1)!modk$\)= k-1$ 有了这个定理,我们就可以很容易得到小于k最大素 ...
分类:
其他好文 时间:
2020-07-29 00:42:21
阅读次数:
80
#pragma warning (disable : 4996) #include<iostream> #include<algorithm> //#include<unordered_map> #include<fstream> #include<iomanip> #include<string> ...
分类:
其他好文 时间:
2020-07-29 00:41:30
阅读次数:
78
编写一个函数来查找字符串数组中的最长公共前缀。 如果不存在公共前缀,返回空字符串 ""。 示例: 输入: ["flower","flow","flight"] 输出: "fl" ##思路 将单词上下排好,则相当于一个各行长度可能不同的二维数组,采用纵向遍历。外围循环为横向遍历,遍历次数由最短单词长度 ...
分类:
其他好文 时间:
2020-07-28 22:25:57
阅读次数:
72
Princess CJB has lived almost her entire life in the isolated town of Ertona, where CJB uses her unique ability to recognize where crystals of materia ...
分类:
其他好文 时间:
2020-07-28 22:14:42
阅读次数:
73
HDU - 1114 题目翻译: 在acm能够做任何事情之前, 必须编制预算并获得必要的财政支持。这一行动的主要收入来自IBM。这个想法其实很简单,每当一些会员有一点小钱时,他就会把所有的硬币都扔到小猪存钱罐里。这个过程是不可逆转的, 除非打破猪,否则硬币不能拿出来。过了足够长的时间, 存钱罐里应该 ...
分类:
其他好文 时间:
2020-07-28 22:08:26
阅读次数:
76
HDU - 4734 题目大致意思:我们定义十进制数x的权值为f(x) = a(n)*2^(n-1)+a(n-1)*2(n-2)+...a(2)*2+a(1)*1,a(i)表示十进制数x中第i位的数字。 题目给出a,b,求出0~b有多少个不大于f(a)的数。 这个f(x)计算就和数位计算是一样的,就 ...
分类:
其他好文 时间:
2020-07-28 22:05:32
阅读次数:
69