传送门 zhx's contest Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)Total Submission(s): 575    Accepted Submission(s): 181 Problem Description As one of the most powerful brushes, zhx is required to give his juniors…
题目分析如果n=1,答案是1,否则答案是2n−2. 证明:ai肯定是最小的或者最大的.考虑另外的数,如果它们的位置定了的话,那么整个序列是唯一的. 那么ai是最小或者最大分别有2n−1种情况,而整个序列单调增或者单调减的情况被算了2次,所以要减2. 要注意的一点是因为p>231,所以要用快速乘法.用法与快速幂相同.如果直接乘会超过long long范围,从而wa掉. 快速幂+快速乘法 #include<cstdio>#include<cstring>#include<c…
题目链接: hdu: http://acm.hdu.edu.cn/showproblem.php?pid=5187 bc(中文): http://bestcoder.hdu.edu.cn/contests/contest_chineseproblem.php?cid=571&pid=1002 题解: 求(2^n-2)%p,题目看错,一天都没什么思路,冷静一下.. 代码: #include<iostream> #include<cstring> #include<cst…
作为史上最强的刷子之一,zhx的老师让他给学弟(mei)们出n道题.zhx认为第i道题的难度就是i.他想要让这些题目排列起来很漂亮. zhx认为一个漂亮的序列{ai}下列两个条件均需满足. 1:a1..ai是单调递减或者单调递增的. 2:ai..an是单调递减或者单调递增的. 他想你告诉他有多少种排列是漂亮的.因为答案很大,所以只需要输出答案模p之后的值. Input Multiply test cases(less than 10001000). Seek EOF as the end of…
zhx's contest Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others) Total Submission(s): 3835    Accepted Submission(s): 1255 Problem Description As one of the most powerful brushes, zhx is required to give his juniors n…
M斐波那契数列 Time Limit: 3000/1000 MS (Java/Others)    Memory Limit: 65535/32768 K (Java/Others)Total Submission(s): 3087    Accepted Submission(s): 953 Problem Description M斐波那契数列F[n]是一种整数数列,它的定义如下: F[0] = aF[1] = bF[n] = F[n-1] * F[n-2] ( n > 1 ) 现在给出a,…
一.取模运算 取模(取余)运算法则: 1. (a+b)%p=(a%p+b%p)%p; 2.(a-b)%p=(a%p-b%p)%p; 3.(a*b)%p=(a%p * b%p)%p; 4.(a^b)%p=(   (a%p)^b  )%p; 5. (  (a+b)%p+c  )%p=( a+(b+c)%p  )%p; 6.( a*(b*c)%p )%p =( c*(a*b)%p )%p; 7.( (a+b)%p*c )%p= ( (a*c)%p + (b*c)%p )%p; 几条重要性质: 1.a≡…
zhx's contest Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others) Total Submission(s): 448    Accepted Submission(s): 147 Problem Description As one of the most powerful brushes, zhx is required to give his juniors n p…
5152. Brute-force Algorithm EXTREME Problem code: BFALG Please click here to download a PDF version of the contest problems. The problem is problem B in the PDF. But the data limits is slightly modified: 1≤P≤1000000 in the original description, but i…
这道题得到了学长的助攻,其实就是一个马尔科夫链,算出一步转移矩阵进行矩阵快速幂就行了,无奈手残 这是我第一回写矩阵快速幂,写的各种毛病,等到调完了已经8点44了,交了一发,返回PE,(发现是少了换行)再想交的时候已经开始hack了 真是TMD.......,然后rejudge完了之后再HDOJ上瞬间AC,真是...狗了,只能是自己手残 手残,手残,手残(重要的事情说三遍) 思路 :(杭电官方题解,我就不班门弄斧了..QAQ) 考虑dpdp,用f_{t,x}f​t,x​​表示第tt秒在xx的概率,…