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 many combinations he can select.
Can you answer his question for all $K(0 \leq K \leq 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 \leq T \leq 300$
$1 \leq N \leq 10^6$

Output
For each test case, output a single integer – LCM modulo $1000000007(109+7)$.

Sample Input
5
1
2
3
4
5

Sample Output
1
2
3
12
10

Author
KUT(DPRK)

解题:看 crazyacking 的解释,涨姿势了

 #include <bits/stdc++.h>
using namespace std;
typedef long long LL;
const int maxn = ;
const int mod = ;
bool np[maxn] = {true,true};
int p[maxn],tot;
void init(){
for(int i = ; i < maxn; ++i){
if(!np[i]) p[tot++] = i;
for(int j = ; j < tot && i*p[j] < maxn; ++j){
np[i*p[j]] = true;
if(i%p[j] == ) break;
}
}
}
int main(){
init();
int kase,n;
scanf("%d",&kase);
while(kase--){
scanf("%d",&n);
LL ret = ;
for(int i = ; i < tot; ++i){
for(LL j = p[i]; j <= n; j *= p[i])
if((n+)%j) ret = ret*p[i]%mod;
}
printf("%I64d\n",ret);
}
return ;
}

2015 Multi-University Training Contest 10 hdu 5407 CRB and Candies的更多相关文章

  1. 2015 Multi-University Training Contest 10 hdu 5406 CRB and Apple

    CRB and Apple Time Limit: 12000/6000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)To ...

  2. 2015 Multi-University Training Contest 10 hdu 5412 CRB and Queries

    CRB and Queries Time Limit: 12000/6000 MS (Java/Others)    Memory Limit: 131072/131072 K (Java/Other ...

  3. 2015 Multi-University Training Contest 10 hdu 5411 CRB and Puzzle

    CRB and Puzzle Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)To ...

  4. 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][ ...

  5. HDU 5407——CRB and Candies——————【逆元+是素数次方的数+公式】

    CRB and Candies Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)T ...

  6. hdu 5407 CRB and Candies(组合数+最小公倍数+素数表+逆元)2015 Multi-University Training Contest 10

    题意: 输入n,求c(n,0)到c(n,n)的所有组合数的最小公倍数. 输入: 首行输入整数t,表示共有t组测试样例. 每组测试样例包含一个正整数n(1<=n<=1e6). 输出: 输出结 ...

  7. 2016 Multi-University Training Contest 10 || hdu 5860 Death Sequence(递推+单线约瑟夫问题)

    题目链接:http://acm.split.hdu.edu.cn/showproblem.php?pid=5860 题目大意:给你n个人排成一列编号,每次杀第一个人第i×k+1个人一直杀到没的杀.然后 ...

  8. 2016 Multi-University Training Contest 10 [HDU 5861] Road (线段树:区间覆盖+单点最大小)

    HDU 5861 题意 在n个村庄之间存在n-1段路,令某段路开放一天需要交纳wi的费用,但是每段路只能开放一次,一旦关闭将不再开放.现在给你接下来m天内的计划,在第i天,需要对村庄ai到村庄bi的道 ...

  9. HDU 5407 CRB and Candies(LCM +最大素因子求逆元)

    [题目链接]pid=5407">click here~~ [题目大意]求LCM(Cn0,Cn1,Cn2....Cnn)%MOD 的值 [思路]来图更直观: 这个究竟是怎样推出的.说实话 ...

随机推荐

  1. GCD&amp;&amp;LCM的一些经典问题

    1.1~n的全部数的最小公倍数:lightoj 1289  传送门 分析:素因子分解可知这个数等于小于1~n的全部素数的最高次幂的乘积 预处理1~n的全部质数,空间较大,筛选的时候用位图来压缩.和1~ ...

  2. 用hadoop实现SimRank++算法(1)----权值转移矩阵的计算

    本文主要针对广告检索领域的查询重写应用,依据查询-广告点击二部图,在MapReduce框架上实现SimRank++算法.关于SimRank++算法的背景和原理请參看前一篇文章<基于MapRedu ...

  3. arcgis server10.2.2公布地图基础服务的详细步骤

    1.直接打开制作好的.mxd文档,比方这里: 2.打开mxd文档之后.打开菜单:file-share as -services 弹出地图公布服务的界面: 点击publish之后,耐心的等待一段时间,地 ...

  4. #leetcode#Anagrames

    Given an array of strings, return all groups of strings that are anagrams. Note: All inputs will be ...

  5. 基于ArcGIS Flex API实现动态标绘(1.0)

    标绘作为一种数据展示形式,在多个行业都有需求. 基于ArcGIS Flex API(3.6)实现标绘API,当前版本号1.0 alpha,支持经常使用几种标绘符号,包含: 圆弧.曲线.圆形.椭圆.弓形 ...

  6. Java图形界面(GUI)——如何将JTable成功放入面板

    在这次课程设计中,大部分内容都设计的很流畅,没有遇到太大的问题,但在面板中加入JTable时确实花费了一部分时间,在此将解决办法总结出来: 定义控件: JPanel panel = new JPane ...

  7. 求int型数据在内存中存储时1的个数

    1.求int型数据在内存中存储时1的个数 输入一个int型数据,计算出该int型数据在内存中存储时1的个数. 我们非常easy想到例如以下方法: #include <iostream> u ...

  8. Swift - 获取当前时间的时间戳(时间戳与时间互相转换)

    (本文代码已升级至Swift3) 1,时间戳 时间戳是指格林威治时间1970年01月01日00时00分00秒(北京时间1970年01月01日08时00分00秒)起至现在的总秒数. 2,获取当前时间的时 ...

  9. Angular2之路由学习笔记

    目前工作中项目的主要技术栈是Angular2 在这里简单记录一下遇到的问题以及解决方案. 这篇笔记主要记录Angular2 的路由. 官方文档链接:https://angular.cn/docs/ts ...

  10. .net core虚拟目录配置

    .net core在iis上配置虚拟目录不起作用,只需要将app.UseStaticFiles中物理路径PhysicalFileProvider改为指定的路径即可,如:E:\\Html\\News a ...