【数论】 HDOJ 5407 CRB and Candies
来源:互联网 发布:淘宝宝贝长图尺寸大小 编辑:程序博客网 时间:2024/05/30 23:06
数论结论题。。。就是1-n+1的lcm除以n+1。。。。不知道结论怎么做?----没法做。。。
#include <bits/stdc++.h>using namespace std;typedef long long LL;const int maxn = 1000005;const int N = 1000000;const int mod = 1e9+7;int val[maxn];LL f[maxn];LL g[maxn];int p[maxn];LL powmod(LL a, LL b){LL res = 1, base = a;while(b) {if(b % 2) res = res * base % mod;base = base * base % mod;b /= 2;}return res;}void init(){for(int i = 2; i < maxn; i++) if(p[i] == 0)for(int j = i + i; j < maxn; j += i) p[j] = 1;for(int i = 2; i < maxn; i++) if(p[i] == 0)for(LL j = (LL)i; j < maxn; j *= i)val[j] = i;f[1] = 1;for(int i = 2; i < maxn; i++) if(val[i]) f[i] = f[i-1] * val[i] % mod;else f[i] = f[i-1];for(int i = 1; i <= N; i++) g[i] = f[i+1] * powmod(i+1, mod-2) % mod;}int main(){init();int _;scanf("%d", &_);while(_--) {int x;scanf("%d", &x);printf("%lld\n", g[x]);}return 0;}
0 0
- 【数论】 HDOJ 5407 CRB and Candies
- Hdoj.5407 CRB and Candies【数论。。。】 2015/12/05
- hdu 5407 CRB and Candies(数论)
- 数论(CRB and Candies,HDU 5407)
- HDU 5407 CRB and Candies 数论
- HDU5407 CRB and Candies 数论
- HDU 5407 CRB and Candies(数论+yy)
- 【HDOJ 5407】 CRB and Candies (大犇推导
- hdu 5407CRB and Candies
- HDU 5407 CRB and Candies
- hdu 5407 CRB and Candies
- hdu 5407 CRB and Candies
- hdu 5407 CRB and Candies(数论,LCM,快速幂取模,求逆元)
- 【数学-求组合数的最小公倍数】HDOJ CRB and Candies 5407
- HDOJ 5407 CRB and Candies(求1到n的LCM 位图储存结构)
- HDU 5407 CRB and Candies (Kummer定理)
- HDU 5407(CRB and Candies-OEIS)
- HDU5407 CRB and Candies
- struts2注解
- 最佳实践之 Android代码规范
- 他所有的情商和智商都还停留在原地,可是,我再却已经走出了好远好远。。。
- 日经春秋 20150821
- wheelview源码
- 【数论】 HDOJ 5407 CRB and Candies
- measure_solder_paster_dff.hdev测量BGA封装焊锡膏深度的 相关例程学习
- 防止ViewPager中的Fragment被销毁的方法
- linux 文件权限
- node-webkit:开发桌面+WEB混合型应用的神器
- php:网上支付
- linux shell 关联数组 hash
- Install and run DB Query Analyzer 6.04 on Microsoft Windows 10
- 【c++】写一个函数,实现x的y次方