NEFU 119 组合素数
2014-05-16 19:21
239 查看
公式没搞懂。。。(( [2*n/p]-2*[n/p] ) + ( [2*n/p^2]-2*[n/p^2] ) +...+ ( [2*n/p^t]-2*[n/p^t] ))其中t = [logp(2*n)]
注意精度
代码如下:
注意精度
代码如下:
#include<iostream> #include<stdio.h> #include<cmath> using namespace std; int main() { int T; scanf("%d",&T); while(T--) { int n,p; double temp; int cnt = 1; int t,ans; scanf("%d%d",&n,&p); temp = log10(2.0*n)*1.0/log10(p); t = int(temp); //printf("temp = %.2lf\n",temp); //printf("t = %d\n",t); ans = 0; for(int i = 1;i <= t;i++) { cnt = cnt*p; ans += (int)(2.0*n/cnt) - 2*(int)(n/cnt); } printf("%d\n",ans); } return 0; }
相关文章推荐
- nefu 119——组合素数
- 【数论】nefu119 组合素数
- nefu 119 组合素数
- NEFU 119 组合素数(数论)
- NEFU 119 组合素数
- nefu119组合素数
- NEFU119 组合素数
- nefu 119 组合素数
- NEFU119 组合素数【算术基本定理】
- NEFU 119 组合素数 (n!素因数p的幂的求法)
- 素因子分解:nefu118(n!后面有多少个0)+ nefu119 (组合素数)
- [NEFU119] 组合素数
- nefu119 组合素数 算术基本定理的应用
- 【Eternallyc】NEFU-119-组合素数
- NEFU 组合素数
- nefu628 组合数取模,模不是素数的情况
- 使用素数解决表示多个标签组合查询
- 素数定理 nefu 117
- NEFU 628 组合数学
- NEFU 120 梅森素数(梅森数素数判定--Lucas-Lehmer测试判定)