HDU 4349 Xiao Ming's Hope】的更多相关文章

非常无语的一个题. 反正我后来看题解全然不是一个道上的. 要用什么组合数学的lucas定理. 表示自己就推了前面几个数然后找找规律. C(n, m) 就是 组合n取m: (m!(n-m!)/n!) 假设n==11 : C(11,0):C(11,1):C(11,2):C(11,3):C(11,4):C(11,5): 分别为 (1/1); (1 / 11) ; (11*10 / 2*1)  ;   (11*10*9 / 3*2*1); (11*10*9*8 / 4*3*2*1) ;  (11*10*…
原题链接:http://acm.hdu.edu.cn/showproblem.php?pid=4349 Xiao Ming's Hope Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 1723    Accepted Submission(s): 1144 Problem Description Xiao Ming likes coun…
Xiao Ming's Hope Time Limit:1000MS     Memory Limit:32768KB  Description Xiao Ming likes counting numbers very much, especially he is fond of counting odd numbers. Maybe he thinks it is the best way to show he is alone without a girl friend. The day…
Xiao Ming's Hope Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Problem Description Xiao Ming likes counting numbers very much, especially he is fond of counting odd numbers. Maybe he thinks it is the best way to…
Xiao Ming's Hope Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 1786    Accepted Submission(s): 1182 Problem Description Xiao Ming likes counting numbers very much, especially he is fond of cou…
有这样一个性质:C(n,m)%p=C(p1,q1)*C(p2,q2).......%p,其中pkpk-1...p1,qkqk-1...q1分别是n,m在p进制下的组成. 就完了. #include<iostream> #include<cstdio> #include<cstring> #include<algorithm> using namespace std; ; int main() { while (scanf("%d",&am…
题目链接 给一个n, 求C(n, 0), C(n, 1), ..........C(n, n)里面有多少个是奇数. 我们考虑lucas定理, C(n, m) %2= C(n%2, m%2)*C(n/2, m/2)%2,   C(n/2, m/2) = C(n/2%2, m/2%2)*C(n/2/2, m/2/2), 这样一直递归下去,直到m为0. 我们知道如果一个数是奇数, 那么它的所有因子都是奇数, 对应于上面的式子, n%2是偶数的时候, m%2也必须是偶数才可以, 而n%2是奇数的时候,…
这种题面真是够了......@小明 题意:the number of odd numbers of C(n,0),C(n,1),C(n,2)...C(n,n). 奇数...就是mod 2=1啊 用Lucas定理,2的幂,就是二进制啊 ${1\choose 1}={1\choose 0}={0\choose 0}=1 \quad {0\choose 1}=0$ 只要二进制有1位n是0而i是1,${n\choose i}$就不是奇数啦 对于n二进制的每一个1,i都有两种选择,答案就是$2^{bitC…
题意:给你n,问在C(n,1),C(n,2)...C(n,n)中有多少个奇数. 比赛的时候打表看出规律,这里给一个数学上的说明. Lucas定理:A,B非负整数,p是质数,A,B化为p进制分别为a[n]a[n-1]...a[0],b[n]b[n-1]...b[0]. 那么组合数C(A,B)与C(a[n],b[n])*...*C(a[0],b[0])模p同余. 证明就不说了,我也不会,给个链接  Lucas定理证明 那再来看这道题就简单了,p=2,C(0,1)=0,C(1,0) = C(1,1)…
Xiao Ming climbing Time Limit: 1 Sec Memory Limit: 256 MB 题目连接 http://bestcoder.hdu.edu.cn/contests/contest_chineseproblem.php?cid=629&pid=1002 Description 小明因为受到大魔王的诅咒,被困到了一座荒无人烟的山上并无法脱离.这座山很奇怪: 这座山的底面是矩形的,而且矩形的每一小块都有一个特定的坐标(x,y)(x,y)和一个高度HH. 为了逃离这座…
题目链接: http://acm.hdu.edu.cn/showproblem.php?pid=5433 Xiao Ming climbing Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)Total Submission(s): 1346    Accepted Submission(s): 384 Problem Description Due to the curse m…
Problem Description   Due to the curse made by the devil,Xiao Ming is stranded on a mountain and can hardly escape. This mountain is pretty strange that its underside is a rectangle which size is n∗m and every little part has a special coordinate(x,y…
题意:给一张地图,给出起点和终点,每移动一步消耗体力abs(h1 - h2) / k的体力,k为当前斗志,然后消耗1斗志,要求到终点时斗志大于0,最少消耗多少体力. 解法:bfs.可以直接bfs,用dp维护最小值……也可以用优先队列优化……但是不能找到终点后就直接输出,因为从不同方向到达终点的消耗不同,终点的前一个状态不一定比这一状态更优……一开始并没有意识到这一点……wa了一篇……后来加了dp维护……但其实在将点弹出的之后再更新vis也可以……以前因为更新vis的问题T过……留下了阴影…… 代…
题意:小明因为受到大魔王的诅咒,被困到了一座荒无人烟的山上并无法脱离.这座山很奇怪: 这座山的底面是矩形的,而且矩形的每一小块都有一个特定的坐标(x,y)和一个高度H. 为了逃离这座山,小明必须找到大魔王,并消灭它以消除诅咒. 小明一开始有一个斗志值k,如果斗志为0则无法与大魔王战斗,也就意味着失败. 小明每一步都能从他现在的位置走到他的(N,E,S,W)(N,E,S,W)(N,E,S,W)四个位置中的一个,会消耗(abs(H​1​​−H​2​​))/k的体力,每走一步消耗一点斗志. 大魔王很强…
题目传送门 题意:求C (n,0),C (n,1),C (n,2)...C (n,n)中奇数的个数 分析:Lucas 定理:A.B是非负整数,p是质数.AB写成p进制:A=a[n]a[n-1]...a[0],B=b[n]b[n-1]...b[0].则组合数C(A,B)与C(a[n],b[n])*C(a[n-1],b[n-1])*...*C(a[0],b[0])  mod p同.即:Lucas (n,m,p)=C (n%p,m%p) * Lucas (n/p,m/p,p)  我是打表找规律的,就是…
Xiao Ming's Hope Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 1668    Accepted Submission(s): 1109 Problem Description Xiao Ming likes counting numbers very much, especially he is fond of cou…
Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others) Total Submission(s): 438    Accepted Submission(s): 108 Problem Description Due to the curse made by the devil,Xiao Ming is stranded on a mountain and can hardly esca…
BUPT2017 wintertraining(15) #8H 题意 求组合数C(n,i),i从0到n,里面有几个奇数. 题解 直接打表的话可能就直接发现规律了. 规律是n的二进制里有几个1,答案就是2的几次方. 证明: lucas定理有:C(n,m)%p=C(n/p,m/p)*C(n%p,m%p)%p 然后取p为2. 所以展开后是C(0,0),C(0,1),C(1,0),C(1,1)的乘积.其中只有C(0,1)=0. 那么C(n,i)%2==1的条件就是n对应位为0,则i对应位必须是0,n对应…
Baby Ming and Matrix games 题意: 给一个矩形,两个0~9的数字之间隔一个数学运算符(‘+’,’-‘,’*’,’/’),其中’/’表示分数除,再给一个目标的值,问是否存在从一个数字出发,以数字之间的运算符为运算,得到这个目标值:(每个数字只能用一次,其实说白了就是dfs..);可以则输出(Impossible),否则输出(Possible); 思路:坑点就是里面本来全是整数,但是一个除法运算却是分数形式,开始使用了很保险的分数保存,来避免误差的.但是无情WA了很多次..…
Problem Description These few days, Baby Ming is addicted to playing a matrix game. Given a n∗m matrix, the character ,j∗) (i,j=,,...) are the numbers between −. There are an arithmetic sign (‘+’, ‘-‘, ‘∗’, ‘/’) between every two adjacent numbers, ot…
Problem Description Baby Ming collected lots of cell phone numbers, and he wants to sell them for money. He thinks normal number can be sold for b yuan, while number with following features can be sold for a yuan. .The last five numbers are the same.…
Problem Description Baby Ming is fond of weight lifting. He has a barbell pole(the weight of which can be ignored) and two different kinds of barbell disks(the weight of which are respectively a and b), the amount of each one being infinite.Baby Ming…
题目链接: PKU:http://poj.org/problem?id=3340 HDU:http://acm.hdu.edu.cn/showproblem.php?pid=2410 Description A wild number is a string containing digits and question marks (like 36?1?8). A number X matches a wild number W if they have the same length, and…
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4772 题面: Zhuge Liang's Password Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 1404    Accepted Submission(s): 926 Problem Description In the anc…
pid=5024">点击打开链接 Wang Xifeng's Little Plot Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others) Total Submission(s): 556    Accepted Submission(s): 362 Problem Description <Dream of the Red Chamber>(also <Th…
分析:裴蜀定理,a,b互质的充要条件是存在整数x,y使ax+by=1.存在整数x,y,使得ax+by=c.那么c就是a,b的公约数. 如果存在数a ,由于对随意x方程都成立.则有当x=1时f(x)=18+ka;有由于f(x)能被65整除,所以f(x)=n*65.即18+ka=n*65有整数解则说明如果成立. ax+by = c的方程有整数解的一个充要条件是:c%gcd(a, b) == 0.然后枚举直到(65*n-18)%k == 0. #include<iostream> using nam…
n积分m文章无向边 它输出一个哈密顿电路 #include <cstdio> #include <cstring> #include <iostream> using namespace std; const int N = 155; int n, m; bool mp[N][N]; int S, T, top, Stack[N]; bool vis[N]; void _reverse(int l,int r) { while (l<r) swap(Stack[l…
题目链接 题解:题意为给出一个N*M的矩阵,然后(i∗2,j∗2) (i,j=0,1,2...)的点处是数字,两个数字之间是符号,其他位置是‘#’号. 但不知道是理解的问题还是题目描述的问题,数据中还有类似1#1这种数据存在,因此WA了4次,加上了一句代码后,马上AC了,该行代码在下文以斜粗体标出. 此外,因为里面有除法,会有一定误差,所以用这句来判断:fabs(tar-nnum)<=1e-8,而不是tar==nnum.   #include <cstdio> #include <…
因为第一行和最后一行都是0,我们只需枚举最左边或最右边一列的01情况,即可得到整张表 然后再检验表是否符合要求 #include<cstdio> #include<cstring> #include<vector> #include<cmath> #include<queue> #include<list> #include<algorithm> using namespace std; int T; int n,m; ]…
#include<cstdio> #include<cstring> #include<vector> #include<cmath> #include<queue> #include<list> #include<algorithm> using namespace std; int T,n; ]; long long a,b; ],q2[]; long long f() { ]==s[]&&s[]==s…