题解:http://bestcoder.hdu.edu.cn/blog/ 多校6 HDU5793 A Boring Question // #pragma comment(linker, "/STACK:102c000000,102c000000") // #include <conio.h> #include <bits/stdc++.h> using namespace std; #define clc(a,b) memset(a,b,sizeof(a))…
题目链接: A Boring Question Time Limit: 2000/1000 MS (Java/Others)     Memory Limit: 65536/65536 K (Java/Others) Problem Description There are an equation.∑0≤k1,k2,⋯km≤n∏1⩽j<m(kj+1kj)%1000000007=?We define that (kj+1kj)=kj+1!kj!(kj+1−kj)! . And (kj+1kj)=…
A Boring Question Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)Total Submission(s): 156    Accepted Submission(s): 72 Problem Description       Input   The first line of the input contains the only integer T,(1≤T…
A Boring Question Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)Total Submission(s): 487    Accepted Submission(s): 271 Problem Description There are an equation.∑0≤k1,k2,⋯km≤n∏1⩽j<m(kj+1kj)%1000000007=? We define…
// 多校5 1001 HDU5781 ATM Mechine // http://acm.hdu.edu.cn/search.php?field=problem&key=2016+Multi-University+Training+Contest+5&source=1&searchmode=source // 记忆化搜索 // 每次二分,决策最优,所以最多查询11次 // dp[i][j] 当前能确定i元情况下,还能被警告j次 // 下次取k,实际剩余t // dp[i][j]=…
HDU 5793 - A Boring Question题意: 计算 ( ∑(0≤K1,K2...Km≤n )∏(1≤j<m) C[Kj, Kj+1]  ) % 1000000007=? (C[Kj, Kj+1] 为组合数)    分析: 利用二项式展开: (a + b) ^ n =  ∑(r = 0, n) (C[n, r] * a^(n-r) * b^r )        化简:           ∑(0≤K1,K2...Km≤n )∏(1≤j<m) C[Kj, Kj+1]       …
题目链接:hdu_5793_A Boring Question 题意: 自己看吧,说不清楚了. 题解: 打表找规律 #include<cstdio> typedef long long ll; ; ll pow(ll a,ll b) { ll an=; while(b){ )an=(an*a)%mod; b>>=,a=(a*a)%mod; } return an; } int main(){ int t,n,m; scanf("%d",&t); whil…
Answers Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 131072/131072 K (Java/Others)Total Submission(s): 25    Accepted Submission(s): 16 Problem Description   Sample Input 2 4 2 2 2 1 0 1 2 3   Sample Output NO YES YES YES   Source 2013 Mul…
Arc of Dream Time Limit: 2000/2000 MS (Java/Others)    Memory Limit: 65535/65535 K (Java/Others)Total Submission(s): 0    Accepted Submission(s): 0 Problem Description An Arc of Dream is a curve defined by following function:wherea0 = A0ai = ai-1*AX+…
Hyperspace Time Limit: 20000/10000 MS (Java/Others)    Memory Limit: 65535/65535 K (Java/Others)Total Submission(s): 67    Accepted Submission(s): 32 Problem Description The great Mr.Smith has invented a hyperspace particle generator. The device is v…
A Boring Question Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)Total Submission(s): 865    Accepted Submission(s): 534 Problem Description There are an equation.∑0≤k1,k2,⋯km≤n∏1⩽j<m(kj+1kj)%1000000007=?We define…
A Boring Question 题目链接: http://acm.hdu.edu.cn/showproblem.php?pid=5793 Description Input The first line of the input contains the only integer T, Then T lines follow,the i-th line contains two integers n,m. Output For each n and m,output the answer i…
/*hdu6061[NTT推公式] 2017多校3*/ #include <bits/stdc++.h> using namespace std; typedef long long LL; ; ; int n, m, temp; LL a; LL inv[]; LL Finv[]; LL F[]; LL A[], B[], C[]; LL quickPow(LL x, LL n, LL MOD) { LL ans = ; ) { ) ans = (ans * x) % MOD; x = (x…
2019牛客多校第二场 A Eddy Walker(概率推公式) 传送门:https://ac.nowcoder.com/acm/contest/882/A 题意: 给你一个长度为n的环,标号从0~n-1,从0号点出发,每次向左走或者向右走的概率是相同的,问你出发后,经过n-1个点后,恰好到达点m的概率是多少,答案是一个前缀积 题解: 讨论两个点的情况: 点0->1的期望是1 讨论三个点的情况 假设我们要到点3,我们必须经过点2,然而我们到了点2可能会再回到点1再到达点3,所以我们讨论必须经过的…
There are an equation. ∑0≤k1,k2,⋯km≤n∏1⩽j<m(kj+1kj)%1000000007=?∑0≤k1,k2,⋯km≤n∏1⩽j<m(kj+1kj)%1000000007=? We define that (kj+1kj)=kj+1!kj!(kj+1−kj)!(kj+1kj)=kj+1!kj!(kj+1−kj)! . And (kj+1kj)=0(kj+1kj)=0 while kj+1<kjkj+1<kj. You have to get th…
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=5324 题意:给你一个二维的序列,让你找出最长的第一维升第二维降的子序列(如果多个答案,输出字典序最小) 解:考虑从后往前dp,在u点你需要知道u点之后的比u的第一维小,第二维大的dp最大值 可以用分治枚举u点之后比u的第一维大的点,然后用树状数组查询比u的第二维小的点中dp最大的 具体是: dp[i]表示以 i 开头的最长子序列,从后往前更新. 更新u点时有u.dp=max(v.dp)+1:v满足v…
Balls Rearrangement Time Limit: 9000/3000 MS (Java/Others)    Memory Limit: 65535/32768 K (Java/Others)Total Submission(s): 25    Accepted Submission(s): 8 Problem Description Bob has N balls and A boxes. He numbers the balls from 0 to N-1, and numbe…
Cut Pieces Time Limit: 4000/2000 MS (Java/Others)    Memory Limit: 131072/65536 K (Java/Others)Total Submission(s): 133    Accepted Submission(s): 62 Problem Description Suppose we have a sequence of n blocks. Then we paint the blocks. Each block sho…
GSM Time Limit: 4000/2000 MS (Java/Others)    Memory Limit: 65535/32768 K (Java/Others)Total Submission(s): 622    Accepted Submission(s): 206 Problem Description Xiao Ming is traveling around several cities by train. And the time on the train is ver…
Palindrome subsequence Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 131072/65535 K (Java/Others)Total Submission(s): 88    Accepted Submission(s): 26 Problem Description In mathematics, a subsequence is a sequence that can be derived from…
Problem Description DouBiXp has a girlfriend named DouBiNan.One day they felt very boring and decided to play some games. The rule of this game is as following. There are k balls on the desk. Every ball has a value and the value of ith (i=1,2,...,k)…
题意:由m个0到n组合的数的相邻两项的组合数的乘积. 思路:好好打表!!!找规律!!! #include<bits/stdc++.h> using namespace std; typedef long long ll; ; ; ; ll mypow(ll a, ll p, ll mo){ ll ret = ; while(p){ ) ret = ret * a % mod; a = a * a % mo; p >>= ; } return ret; } int main(){ l…
找出的规律.... 1 2 3 2 2 7 3 2 15 4 2 31 5 2 63 1 3 4 2 3 13 3 3 40 4 3 121 5 3 361 然后我们来推个公式: 比如说a2=3a1+1, 我们可以看到 等比是m, 然后凑一下, 1+x=m*x x=1/(m-1) 上面那个例子就凑成了这个样子, (a2+1/2)/(a1+1/2)=3 所以首项是:m+1+[1/(m-1)] 第n项是:[m+1+1/(m-1)]*m^(n-1) 答案是:[m+1+1/(m-1)]*m^(n-1)-…
参考博客:http://www.cnblogs.com/Sunshine-tcf/p/5737627.html. 说实话,官方博客的推导公式看不懂...只能按照别人一样打表找规律了...但是打表以后其实也不是很好看出规律的...而且这个表都写了半天233...(真是太弱了= =)为了打表,我们应当先知道k数列必须是不递减的才能满足值不为0,因此我们可以用递归来写这个表(类似于dfs). AC代码如下: #include <stdio.h> #include <algorithm>…
There are an equation. ∑0≤k1,k2,⋯km≤n∏1⩽j<m(kj+1kj)%1000000007=? We define that (kj+1kj)=kj+1!kj!(kj+1−kj)! . And (kj+1kj)=0 while kj+1<kj. You have to get the answer for each n and m that given to you. For example,if n=1,m=3, When k1=0,k2=0,k3=0,(k…
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=6128 题意:给你n个数,问你有多少对i,j,满足i<j,并且1/(ai+aj)=1/ai+1/aj 在%p意义下. 解法:官方题解说是用二次剩余来解,但是我并不会这玩意了.在网上看到一位大佬没有二次剩余直接通过推公式做出了这题,真是神奇.http://www.cnblogs.com/bin-gege/p/7367337.html  将式子通分化简后可得(ai2+aj2+ai*aj)%p=0 .然后两…
description qwb同时也是是之江学院的志愿者,暑期要前往周边地区支教,为了提高小学生的数学水平.她把小学生排成一排,从左至右从1开始依次往上报数. 玩完一轮后,他发现这个游戏太简单了.于是他选了3个不同的数x,y,z:从1依次往上开始报数,遇到x的倍数.y的倍数或z的倍数就跳过.如果x=2,y=3,z=5:第一名小学生报1,第2名得跳过2.3.4.5.6,报7:第3名得跳过8.9.10,报11. 那么问题来了,请你来计算,第N名学生报的数字是多少? input 多组测试数据,处理到文…
Problem Description 近期B厂组织了一次大搬家,所有人都要按照指示换到指定的座位上.指示的内容是坐在位置i 上的人要搬到位置j 上.现在B厂有N 个人,一对一到N 个位置上.搬家之后也是一一对应的,改变的只有位次. 在第一次搬家后,度度熊由于疏忽,又要求大家按照原指示进行了一次搬家.于是,机智的它想到:再按这个指示搬一次家不就可以恢复第一次搬家的样子了.于是,B厂史无前例的进行了连续三次搬家. 虽然我们都知道度度熊的“机智”常常令人堪忧,但是不可思议的是,这回真的应验了.第三次…
我只能说: A Boring Question 下面公式重复了一行 \[ \sum\_{0\leq k\_{1},k\_{2},\cdots k\_{m}\leq n}\prod\_{1\leq j< m}\binom{k\_{j+1}}{k\_{j}} \\\ =\sum\_{0\leq k\_{1}\leq k\_{2}\leq\cdots \leq k\_{m}\leq n}\prod\_{1\leq j< m}\binom{k\_{j+1}}{k\_{j}} \\\ =\sum\_{k…
这场就做出一道题,怎么会有窝这么辣鸡的人呢? 1001 A Boring Question(hdu 5793) 很复杂的公式,打表找的规律,最后是m^0+m^1+...+m^n,题解直接是(m^(n+1)-1)/(m-1),长姿势,原来还能化简…… 我既然不会推公式,也没啥好写的.写一下我打表的代码吧…… #include <cstdio> typedef long long ll; int n, m; ll sum; ll fac[]; ]; void init() { fac[] = ;…