2015 Multi-University Training Contest 10 hdu 5407 CRB and Candies
2015-08-22 10:03
411 查看
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
[align=left]Problem Description[/align]
[align=left] [/align]
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 = 1000002; const int mod = 1000000007; bool np[maxn] = {true,true}; int p[maxn],tot; void init(){ for(int i = 2; i < maxn; ++i){ if(!np[i]) p[tot++] = i; for(int j = 0; j < tot && i*p[j] < maxn; ++j){ np[i*p[j]] = true; if(i%p[j] == 0) break; } } } int main(){ init(); int kase,n; scanf("%d",&kase); while(kase--){ scanf("%d",&n); LL ret = 1; for(int i = 0; i < tot; ++i){ for(LL j = p[i]; j <= n; j *= p[i]) if((n+1)%j) ret = ret*p[i]%mod; } printf("%I64d\n",ret); } return 0; }
View Code
相关文章推荐
- Aborting commit: 'XXXXXXXX'remains in conflict错误
- Climbing Stairs
- JUnit3 结合一个除法的单元测试说明Assert.fail()的用法
- poj 1995 Raising Modulo Numbers 【快速幂 裸题】
- aiSee3 矢量图像文本格式 示例
- POJ 3411 Paid Roads
- LeetCode "Paint House"
- hdu 5316 Magician 2015 Multi-University Training Contest 3
- 关于pkg: /data/local/tmp/com.example.zy.deyijia Failure [INSTALL_FAILED_OLDER_SD问题
- 【LeetCode】(172)Factorial Trailing Zeroes(Easy)
- uva 11168 - Airport(凸包)
- Selenium 高阶应用之WebDriverWait 和 expected_conditions
- Selenium 高阶应用之WebDriverWait 和 expected_conditions
- 2015 Multi-University Training Contest 10 hdu 5411 CRB and Puzzle
- wget+webmin+dns+lamp+openwebmail
- hdu1021Fibonacci Again
- [杂谈]机器学习:数学、概率与人工智能
- Codeforces Gym 100338H High Speed Trains 组合数学+dp+高精度
- ip,email,银行卡号匹配
- 03-树3. Tree Traversals Again (25)将先序遍历和中序遍历转为后序遍历