【Violet 5】【BZOJ2721】樱花
2015-11-03 07:59
387 查看
Description
Input
Output
Sample Input
3
Sample Output
9
HINT
Source
interviewstreet–EQUATIONS
我良心的在这里给泥萌加上了样例>_<
SD2015省队集训Week1的测试题
首先显然x>n!,y>n!,那么我们选择令y=n!+z
则显然有x=n!2z+n!
求出n!2的约数个数就行了
答案记得开longlong,中间过程会炸
Input
Output
Sample Input
3
Sample Output
9
HINT
Source
interviewstreet–EQUATIONS
我良心的在这里给泥萌加上了样例>_<
SD2015省队集训Week1的测试题
首先显然x>n!,y>n!,那么我们选择令y=n!+z
则显然有x=n!2z+n!
求出n!2的约数个数就行了
答案记得开longlong,中间过程会炸
#include<iostream> #include<cstdio> #include<cstring> #include<cmath> #include<algorithm> #define MAXN 1000010 #define P 1000000007 using namespace std; int n; long long ans=1; int prime[MAXN],top,fac[MAXN]; bool not_prime[MAXN]; int cnt[MAXN]; void check_prime() { for (int i=2;i<=n;i++) { if (!not_prime[i]) prime[++top]=i,fac[i]=top; for (int j=1;j<=top&&i*prime[j]<=n;j++) { not_prime[i*prime[j]]=1;fac[i*prime[j]]=j; if (i%prime[j]==0) break; } } } void calc(int x) { while (x!=1) cnt[fac[x]]++,x/=prime[fac[x]]; } int main() { scanf("%d",&n); check_prime(); for (int i=1;i<=n;i++) calc(i); for (int i=1;i<=top;i++) ans=ans*((2*cnt[i]+1)%P)%P; cout<<ans<<endl; }
相关文章推荐
- 1.m分解阶乘之和
- 2.几种递推数
- 3.欧拉函数
- 4.快速幂模m算法
- 5.扩展欧几里得&&中国剩余定理
- 6.数论_web
- Project Euler Problem 387 - Harshad Numbers - 深度优先
- 编程之美2015初赛A
- 数论题集
- 原根
- 阶与原根学习笔记
- HDU 1299 Diophantus of Alexandria
- Leftmost Digit(HDU 1060)
- Rightmost Digit(HDU 1061)
- ZOJ 2674 Strange Limit 欧拉定理
- LeetCode-Palindrome Number
- 组合数求模总结
- 【数论】组合数求模
- [BZOJ1041][HAOI2008][数学乱搞]圆上的整点
- HDU 5341 Gcd and Lcm