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 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 least common multiple(LCM) of all answers.
Input
There are multiple test cases. The first line of input contains an integer T, indicating the number of test cases. For each test case there is one line containing a single integer N.
1 ≤ T ≤ 300
1 ≤ N ≤ 106
Output
For each test case, output a single integer – LCM modulo 1000000007(109+7).
Sample Input
Sample Output
Author
KUT(DPRK)
这个题我是知道(n+1)*LCM(C(n,0),C(n,1)..C(n,n)) = LCM(1,2,3..n) 这个公式的,但是用错了方法求(1-n)的LCM。。(也就是经常用的那个lcm(a,b) = a/gcd(a,b)*b)但是这个公式里面是不允许取模的。。所以一直弄不出来。。然后在网上看到了很牛逼的公式。。数论真是很神奇啊。
aaarticlea/png;base64,iVBORw0KGgoAAAANSUhEUgAAAZgAAABlCAIAAAD/ImJxAAAaoUlEQVR4nO2dT2gbyZ7H61YHEYQOTQ6NEEII7yCM8EoHYREGmVmbEGjkJTxhSDMwwoP9WB0s1gmrHeIJrHfTLDjwoiHiDfbMQ8wzXmtJ8yb2TkQECWaiMM8eEKMhThhNGCsEkUMfBh36VnuoltTd6pa6pdY/uz6nRHKX6l9/u+pX1fUFiEAgECYcMOoMEAgEQr8QISMQCBMPETICgTDxECEjEAgTDxEy6xBfP9t/8vPvQ7+2M9UXDx+d1AaQMGZiM45qJ48evqgOIOHff36y/+y1OICUh8Dg2hMhpN2oltTXuRCywk2vi7ZDAAAA0E67XK7Q3WOtPxSFn/ZuMyHaDm2Uy0VR7ih3VKsdpYKe9SNckZUvGVczLd9mqT2NSiYCmz/U+h2xtDVrD26e1NV/X3/zJP3pnI+yQTvtoikqsJJ7XX+dXaQWdmrdrrWEGs9SFMubloTulTW5GUc1Pk7TbK46ELkRS1zQFuRK46VlI++ICCHtRrWivs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牛也不一定能够解出来吧。。
还有一个人的题解提供了一种方法,不过没看懂,但是他提供了一种求解最小公倍数的方法。
---------------------------------------------------------------------------------------------------------------------------------------------------------------
分解质因数法:
先把这几个数分解质因数,再把它们一切公有的质因数和其中几个数公有的质因数以及每个数的独有的质因数全部连乘起来,所得的积就是它们的最小公倍数。
例如,求LCM[12,18,20,60]
因为12=(2)×[2]×[3],18=(2)×[3]×3,20=(2)×[2]×{5},60=(2)×[2]×[3]×{5}
其中四个数的公有的质因数为2(小括号中的数),
三个数的公有的质因数为2与3[中括号中的数],
两个数的公有的质因数为5{大括号中的数},
每个数独有的质因数为3。
所以,[12,18,20,60]=2×2×3×3×5=180。
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <string.h>
using namespace std;
typedef long long LL;
const int N = ;
const LL mod = ;
LL f[N];
LL gcd(LL a,LL b){
return b==?a:gcd(b,a%b);
}
LL extend_gcd(LL a,LL b,LL &x,LL &y){
if(!b){
x=,y = ;
return a;
}else{
LL x1,y1;
LL d = extend_gcd(b,a%b,x1,y1);
x = y1;
y = x1 - a/b*y1;
return d;
}
}
LL mod_reverse(LL a,LL n)
{
LL x,y;
LL d=extend_gcd(a,n,x,y);
if(d==) return (x%n+n)%n;
else return -;
}
int prime[N];
LL F[N];
bool only_divide(int n){
int t = prime[n];
while(n%t==){
n/=t;
}
if(n==) return true;
return false;
}
void init(){
for(int i=;i<N;i++){
prime[i] = i;
}
for(int i=;i<N;i++){ ///十分巧妙的一步,判断某个数是否只有唯一的质因子,只需要把每个数的倍数存下来
if(prime[i]==i){
for(int j=i+i;j<N;j+=i){
prime[j] = i;
}
}
}
F[] = ;
for(int i=;i<N;i++){
if(only_divide(i)){
F[i] = F[i-]*prime[i]%mod;
}else F[i] = F[i-];
}
}
int main()
{
init();
int tcase;
scanf("%d",&tcase);
while(tcase--)
{
int n;
scanf("%d",&n);
LL inv = mod_reverse((n+),mod);
printf("%lld\n",F[n+]*inv%mod);
}
return ;
}
- HDU 5407(2015多校10)-CRB and Candies(组合数最小公倍数+乘法逆元)
题目地址:pid=5407">HDU 5407 题意:CRB有n颗不同的糖果,如今他要吃掉k颗(0<=k<=n),问k取0~n的方案数的最小公倍数是多少. 思路:首先做这道 ...
- Hdu 5407 CRB and Candies (找规律)
题目链接: 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][ ...
- HDU 5407 CRB and Candies(LCM +最大素因子求逆元)
[题目链接]pid=5407">click here~~ [题目大意]求LCM(Cn0,Cn1,Cn2....Cnn)%MOD 的值 [思路]来图更直观: 这个究竟是怎样推出的.说实话 ...
- hdu 5407【LCM性质】+【逆元】(结论题)
<题目链接> <转载于 >>> > Problem Description CRB has N different candies. He is going ...
- LCM性质 + 组合数 - HDU 5407 CRB and Candies
CRB and Candies Problem's Link Mean: 给定一个数n,求LCM(C(n,0),C(n,1),C(n,2)...C(n,n))的值,(n<=1e6). analy ...
- HDU 5407——CRB and Candies——————【逆元+是素数次方的数+公式】
CRB and Candies Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others)T ...
- hdu 5407 CRB and Candies(组合数+最小公倍数+素数表+逆元)2015 Multi-University Training Contest 10
题意: 输入n,求c(n,0)到c(n,n)的所有组合数的最小公倍数. 输入: 首行输入整数t,表示共有t组测试样例. 每组测试样例包含一个正整数n(1<=n<=1e6). 输出: 输出结 ...
- hdu 5407
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=5407 题意:给定一个数n,求LCM(C(n,0),C(n,1),C(n,2)...,C(n,n)) 根 ...
- Harvest of Apples (HDU多校第四场 B) (HDU 6333 ) 莫队 + 组合数 + 逆元
题意大致是有n个苹果,问你最多拿走m个苹果有多少种拿法.题目非常简单,就是求C(n,0)+...+C(n,m)的组合数的和,但是询问足足有1e5个,然后n,m都是1e5的范围,直接暴力的话肯定时间炸到 ...
随机推荐
- Python3中的编码问题
编码方式介绍 我们首先来熟悉一下常见的一些编码方式,按照时间轴来划分,共有以下几种编码方式(常见): ASCII编码方式:对127个常见字符进行编码,其中包含了10个阿拉伯数字,共52个大小写英文字母 ...
- 使用alien命令让deb包和rpm包互相转换
OS version: CentOS7 / Debian9 发现alien这个命令时很惊喜,之前在debian上安装etcd找不到安装包感觉很不科学,有了alien命令事情一下就变简单了. 这里以et ...
- GO进程调度相关源码学习
启动流程 procresize流程 malloc.go Memory allocator sizeclass.go span按大小区分的 类型定义 mbitmap.go type and heap b ...
- Flask-SQLAlchemy 无法创建Sqlite 数据库???
<Flask web 开发>第五章数据库照书中的方法无法创建表,没有python的命令提示符,只是运行程序输入db.create_all()后文件夹里也没有data.sqlite文件 解决 ...
- Python内置的操作系统模块(os)与解释器交互模块(sys)
Python内置的操作系统模块(os)与解释器交互模块(sys) 作者:尹正杰 版权声明:原创作品,谢绝转载!否则将追究法律责任. 本片博客只介绍Python调用操作系统的模块即os模块,以及Pyth ...
- JDBC编程示例
package com.lovo.test; import java.sql.Connection;import java.sql.DriverManager;import java.sql.SQLE ...
- bzoj千题计划222:bzoj2329: [HNOI2011]括号修复(fhq treap)
http://www.lydsy.com/JudgeOnline/problem.php?id=2329 需要改变的括号序列一定长这样 :)))((( 最少改变次数= 多余的‘)’/2 [上取整] + ...
- 流媒体技术学习笔记之(六)FFmpeg官方文档先进音频编码(AAC)
先进音频编码(AAC)的后继格式到MP3,和以MPEG-4部分3(ISO / IEC 14496-3)被定义.它通常用于MP4容器格式; 对于音乐,通常使用.m4a扩展名.第二最常见的用途是在MKV( ...
- 用matplotlib制作的比较满意的蜡烛图
用matplotlib制作的比较满意的蜡烛图 2D图形制作包, 功能强大, 习练了很久, 终于搞定了一个比较满意的脚本. 特点: 使用方面要非常简单 绘制出来的图要非常的满意, 具有如下的特点 时间和 ...
- 安装mongodb以及设置为windows服务 详细步骤
我的win7 32的,注意版本要正确! 一.下载mongodb压缩包:mongodb-win32-i386-2.6.9.zip() 二.在D盘新建文件夹mongodb,将压缩我的解压文件放进去(有一个 ...