一.桶排思想 1.通过构建n个空桶再将待排各个元素分配到每个桶.而此时有可能每个桶的元素数量不一样,可能会出现这样的情况:有的桶没有放任何元素,有的桶只有一个元素,有的桶不止一个元素可能会是2+: 2.按照下标对内容非0的桶按个数输出下标: 二.[USACO08DEC]Patting Heads题解 Description -It's Bessie's birthday and time for party games! Bessie has instructed the N (1 <= N <…
P2926 [USACO08DEC]拍头Patting Heads 题目描述 It's Bessie's birthday and time for party games! Bessie has instructed the N (1 <= N <= 100,000) cows conveniently numbered 1..N to sit in a circle (so that cow i [except at the ends] sits next to cows i-1 and…
题目描述 It's Bessie's birthday and time for party games! Bessie has instructed the N (1 <= N <= 100,000) cows conveniently numbered 1..N to sit in a circle (so that cow i [except at the ends] sits next to cows i-1 and i+1; cow N sits next to cow 1). Me…
It's Bessie's birthday and time for party games! Bessie has instructed the N (1 <= N <= 100,000) cows conveniently numbered 1..N to sit in a circle (so that cow i [except at the ends] sits next to cows i-1 and i+1; cow N sits next to cow 1). Meanwhi…
Description It's Bessie's birthday and time for party games! Bessie has instructed the N (1 < N < 100,000) cows conveniently numbered 1..N to sit in a circle (so that cow i [except at the ends] sits next to cows i-1 and i+1; cow N sits next to cow 1…
筛法. 枚举每个数,它会对它的倍数的答案有贡献. 数大了以后,倍数相应少了很多.比枚举每个数的约数要好的多. 自己yy了一种分步做法.小于sqrt(m)被当作约数枚举,大于sqrt(m)的枚举倍数. #include<cstdio> #include<algorithm> #include<cstring> using namespace std; + ; int a[maxn],cnt[maxn]; int n,maxa,s[maxn]; int main() { s…
某种意义上真毒瘤?我没看懂题啊...于是看了题解 就是筛约数的那种方法,复杂度调和级数保证O(nlogn) 所以这题啥意思啊 #include<iostream> #include<cstdio> #include<algorithm> using namespace std; const int N=1000005; int n,mx,a[N],c[N],d[N]; int read() { int r=0,f=1; char p=getchar(); while(p…