[题目链接]pid=5407">click here~~ [题目大意]求LCM(Cn0,Cn1,Cn2....Cnn)%MOD 的值 [思路]来图更直观: 这个究竟是怎样推出的.说实话.本人数学归纳大法没有推出来,幸得一个大神给定愿文具体证明.点击这里:click here~~ 代码: #include <bits/stdc++.h> using namespace std; const int N=1e6+10; const int MOD=1e9+7; typedef lo…
题目链接: Hdu 5407 CRB and Candies 题目描述: 给出一个数n,求lcm(C(n,0),C[n,1],C[n-2]......C[n][n-2],C[n][n-1],C[n][n])%(1e9+7)是多少? 解题思路: 刚开始的时候各种开脑洞,然后卡题卡的风生水起.最后就上了数列查询这个神奇的网站,竟然被我找到了!!!!就是把题目上给的问题转化为求lcm(1, 2, 3, 4 ...... n-2, n-1, n, n-1) / (n+1),扎扎就打了两个表一个lcm[n…
CRB and Candies Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)Total Submission(s): 722    Accepted Submission(s): 361 Problem Description CRB has N different candies. He is going to eat K candies.He wonders how ma…
CRB and Candies Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)Total Submission(s): 453    Accepted Submission(s): 222 Problem Description   CRB has N different candies. He is going to eat K candies.He wonders how…
CRB and Candies Problem's Link Mean: 给定一个数n,求LCM(C(n,0),C(n,1),C(n,2)...C(n,n))的值,(n<=1e6). analyse: 很有趣的一道数论题! 看了下网上别人的做法,什么Kummer定理我还真没听说过,仔细研究一下那个鬼定理真是涨姿势了! 然而这题我并不是用Kummer那货搞的(what?). 其实这题真的很简单(不要打我),为什么这样说呢?看了下面的解释你就知道我没骗你. 首先我们看一下这个式子:LCM(C(n,0…
题意:给一个正整数k,求lcm((k, 0), (k, 1), ..., (k, k)) 解法:在oeis上查了这个序列,得知答案即为lcm(1, 2, ..., k + 1) / (k + 1),而分子有一个递推式,如果k为一个质数x的某次幂,那么ans[k]为ans[k - 1] * m,否则ans[k] = ans[k - 1].做除法的时候用了逆元,因为取模来着. 代码: #include<stdio.h> #include<iostream> #include<al…
题意: 输入n,求c(n,0)到c(n,n)的所有组合数的最小公倍数. 输入: 首行输入整数t,表示共有t组测试样例. 每组测试样例包含一个正整数n(1<=n<=1e6). 输出: 输出结果(mod 1e9+7). 感觉蛮变态的,从比赛开始我就是写的这道题,比赛结束还是没写出来…… 期间找到了逆元,最小公倍数,组合数的各种公式,但是爆了一下午tle. 比赛结束,题解告诉我,公式秒杀法…… 但是公式看不懂,幸好有群巨解说,所以有些听懂了,但还是需要继续思考才能弄懂. 题解: 设ans[i]表示i…
题目 CRB and Candies 题意 \[ \text{给定正整数N,求} LCM \lbrace C \left(N , 0 \right),C\left(N , 1 \right),...,C\left(N , N \right) \rbrace \% mod \qquad 1\leq N \leq 10^6 \] 题解 根据规律推出公式,另外关于这个公式的证明 \[ LCM \lbrace C \left(N , 0 \right),C\left(N , 1 \right),...,…
题目传送门 题意:求LCM (C(N,0),C(N,1),...,C(N,N)),LCM是最小公倍数的意思,C函数是组合数. 分析:先上出题人的解题报告 好吧,数论一点都不懂,只明白f (n + 1)意思是前n+1个数的最小公倍数,求法解释参考HDOJ 1019,2028 这个结论暂时不知道怎么推出来的,那么就是剩下1/(n+1) 逆元的求法了 代码: /************************************************ * Author :Running_Time…
题目地址:pid=5407">HDU 5407 题意:CRB有n颗不同的糖果,如今他要吃掉k颗(0<=k<=n),问k取0~n的方案数的最小公倍数是多少. 思路:首先做这道题我们须要必备的几个技能点. 1. LCM(C(n,0), C(n,1),-, C(n,n))=LCM(1,2,3,-n+1)/(n+1).额,这个有一篇证明Kummer定理 2.(1) 乘法逆元定义: 满足a*k≡1 (mod p)的k值就是a关于p的乘法逆元(a,p互质). (2)为什么要用乘法逆元: 当…
pid=5407">[HDOJ 5407] CRB and Candies 赛后看这题题解仅仅有满眼的迷茫------ g(N) = LCM(C(N,0),C(N,1),...,C(N,N)) f(n)\ =\ LCM(1, 2, ..., n)f(n) = LCM(1,2,...,n), the fact g(n)\ =\ f(n+1) / (n+1)g(n) = f(n+1)/(n+1) f(n)\ =\ LCM(1, 2, ..., n)f(1) = 1 If n\ =p^{k}n …
CRB and Candies Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)Total Submission(s): 947    Accepted Submission(s): 442 Problem Description CRB has N different candies. He is going to eat K candies.He wonders how ma…
HDU5407 CRB and Candies 题意: 计算\(LCM(C(n,0),C(n,1),C(n,2),\cdots,C(n,n-1),C(n,n))\) \(n\le 10^6\) 题解: 规律: \(LCM(C(n,0),C(n,1),C(n,2),\cdots,C(n,n-1),C(n,n)) = \frac{LCM(1,2,3,\cdots,,n-1,n,n+1)}{n+1}\) 令\(g(n)=LCM(C(n,0),C(n,1),C(n,2),\cdots,C(n,n-1),…
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=5407 题意:给定一个数n,求LCM(C(n,0),C(n,1),C(n,2)...,C(n,n)) 根据官方题解,g(n) = LCM(C(n,0),C(n,1),C(n,2)...,C(n,n)) g(n) = f(n+1)/(n+1) 而    f(n) = LCM(1,2,3,...,n) 对于f(n)中的每一个数,对LCM的贡献值并不一样,可以想一下,对n进行因式分解,n = p1^x1*p…
hdu 6126 Give out candies(最小割) 题意: 有\(n\)个小朋友,标号为\(1\)到\(n\),你要给每个小朋友至少\(1\)个且至多\(m\)个的糖果.小朋友们共提出\(k\)个要求,每个要求包括三个整数\(x,y,z\),表示\(x\)号小朋友得到的糖果数减去\(y\)号小朋友得到的糖果数,结果应当不大于\(z\).如果你给\(i\)号小朋友\(j\)颗糖果,他会获得\(w_{i,j}\) 的满意度,你需要最大化所有小朋友的满意度之和.\(1\leq n,m\leq…
题目链接: Hdu 5416 CRB and Tree 题目描述: 给一棵树有n个节点,树上的每条边都有一个权值.f(u,v)代表从u到v路径上所有边权的异或值,问满足f(u,v)==m的(u, v)有多少中情况(u, v有可能相同)? 解题思路: 由于xor的特殊性质.x^x=0,对于求f(u, v) == f(u, 1) ^ f(1, u). 又因为x^y == z可以推出x^z == y,对于f(u, 1) ^ f(1, v) == m可以转化为m ^ f(1, v) == f(u, 1)…
看了标程的压位,才知道压位也能很容易写- - /* HDU 6085 - Rikka with Candies [ 压位 ] | 2017 Multi-University Training Contest 5 题意: 给定 A[N], B[N], Q 个 k 对于每个k, 求 A[i] % B[j] == k 的 (i,j)对数 限制 N, Q <=50000 分析: 对于每个 B[i] 按其倍数分块,则对于 A[j] ∈ [x*B[i],(x+1)*B[i]) , A[j]%B[i] = A…
Birthday Toy Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 644    Accepted Submission(s): 326 Problem Description AekdyCoin loves toys. It is AekdyCoin’s Birthday today and he gets a special “…
数论入门2 另一种类型的数论... GCD,LCM 定义\(gcd(a,b)\)为a和b的最大公约数,\(lcm(a,b)\)为a和b的最小公倍数,则有: 将a和b分解质因数为\(a=p1^{a1}p2^{a2}p3^{a3}...pn^{an},b=p1^{b1}p2^{b2}p3^{b3}...pn^{bn}\),那么\(gcd(a,b)=\prod_{i=1}^{n}pi^{min(ai,bi)},lcm(a,b)=\prod_{i=1}^{n}pi^{max(ai,bi)}\)(0和任何…
地址:http://acm.hdu.edu.cn/showproblem.php?pid=5768 Lucky7 Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others) Problem Description When ?? was born, seven crows flew in and stopped beside him. In its childhood, ?? had be…
HDU 1394 Minimum Inversion Number(线段树求最小逆序数对) ACM 题目地址:HDU 1394 Minimum Inversion Number 题意:  给一个序列由[1,N]构成.能够通过旋转把第一个移动到最后一个.  问旋转后最小的逆序数对. 分析:  注意,序列是由[1,N]构成的,我们模拟下旋转,总的逆序数对会有规律的变化.  求出初始的逆序数对再循环一遍即可了. 至于求逆序数对,我曾经用归并排序解过这道题:点这里.  只是因为数据范围是5000.所以全…
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=5407 题目: Problem Description CRB has N different candies. He is going to eat K candies.He wonders how many combinations he can select.Can you answer his question for all K(0 ≤ K ≤ N)?CRB is too hungry to…
<题目链接> <转载于 >>> > Problem Description CRB has N different candies. He is going to eat K candies.He wonders how many combinations he can select.Can you answer his question for all K(0 ≤ K ≤ N)?CRB is too hungry to check all of your ans…
Problem Description CRB has N different candies. He is going to eat K candies.He wonders how many combinations he can select.Can you answer his question for all K (0 ≤ K ≤ N )?CRB is too hungry to check all of your answers one by one, so he only asks…
CRB and Tree Time Limit: 8000/4000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others) Total Submission(s): 2112    Accepted Submission(s): 635 Problem Description CRB has a tree, whose vertices are labeled by 1, 2, …, N. They are connected…
CRB and His Birthday Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)Total Submission(s): 430    Accepted Submission(s): 237 Problem Description Today is CRB's birthday. His mom decided to buy many presents for her…
题目连接 http://acm.hdu.edu.cn/showproblem.php?pid=5412 CRB and Queries Description There are $N$ boys in CodeLand. Boy i has his coding skill $A_{i}$. CRB wants to know who has the suitable coding skill. So you should treat the following two types of qu…
Problem Description Today is CRB's birthday. His mom decided to buy many presents for her lovely son. She went to the nearest shop with M Won(currency unit). At the shop, there are N kinds of presents. It costs Wi Won to buy one present of i-th kind.…
Give out candies Time Limit: 6000/3000 MS (Java/Others)    Memory Limit: 524288/524288 K (Java/Others)Total Submission(s): 218    Accepted Submission(s): 66 Problem Description There are n children numbered 1 to n, and HazelFan's task is to give out…
题目链接:http://acm.hdu.edu.cn/showproblem.php? pid=5412 Problem Description There are N boys in CodeLand. Boy i has his coding skill Ai. CRB wants to know who has the suitable coding skill. So you should treat the following two types of queries. Query 1…