poj1992 数论
//Accepted 168 KB 969 ms
//n!中含有质因数p的个数为t=n/p+n/p^2+n/p^3+...
#include <cstdio>
#include <cstring>
#include <iostream>
using namespace std;
;
int pri[imax_n];
void prime()
{
;i<imax_n;i++)
{
for (int j=i*i;j<imax_n;j+=i)
{
pri[j]=;
}
}
}
int getNumber(int n,int k)
{
;
)
{
ans+=n/k;
n=n/k;
}
return ans;
}
void slove(int n,int k)
{
__int64 ans=;
;i<=n;i++)
)
{
;
ans*=t;
}
printf("%I64d\n",ans);
}
int main()
{
prime();
int n,k;
while (scanf("%d%d",&n,&k)!=EOF)
{
slove(n,k);
}
;
}
//Accepted 900 KB 344 ms
#include <cstdio>
#include <cstring>
#include <iostream>
using namespace std;
;
int pri[imax_n];
int a[imax_n][imax_n];
void prime()
{
;i<imax_n;i++)
{
for (int j=i*i;j<imax_n;j+=i)
{
pri[j]=;
}
}
}
int getNumber(int n,int k)
{
;
)
{
ans+=n/k;
n=n/k;
}
return ans;
}
void getA()
{
;i<=;i++)
{
;j<=;j++)
{
)
a[i][j]=getNumber(i,j);
}
}
}
void slove(int n,int k)
{
__int64 ans=;
;i<=n;i++)
)
{
//printf("a[%d][%d]=%d\n",n,i,a[n][i]);
//printf("a[%d][%d]=%d\n",k,i,a[k][i]);
//printf("a[%d][%d]=%d\n",n-k,i,a[n-k][i]);
;
ans*=t;
}
printf("%I64d\n",ans);
}
int main()
{
prime();
getA();
int n,k;
while (scanf("%d%d",&n,&k)!=EOF)
{
slove(n,k);
}
;
}
poj1992 数论的更多相关文章
- Codeforces Round #382 Div. 2【数论】
C. Tennis Championship(递推,斐波那契) 题意:n个人比赛,淘汰制,要求进行比赛双方的胜场数之差小于等于1.问冠军最多能打多少场比赛.题解:因为n太大,感觉是个构造.写写小数据, ...
- NOIP2014 uoj20解方程 数论(同余)
又是数论题 Q&A Q:你TM做数论上瘾了吗 A:没办法我数论太差了,得多练(shui)啊 题意 题目描述 已知多项式方程: a0+a1x+a2x^2+..+anx^n=0 求这个方程在[1, ...
- 数论学习笔记之解线性方程 a*x + b*y = gcd(a,b)
~>>_<<~ 咳咳!!!今天写此笔记,以防他日老年痴呆后不会解方程了!!! Begin ! ~1~, 首先呢,就看到了一个 gcd(a,b),这是什么鬼玩意呢?什么鬼玩意并不 ...
- hdu 1299 Diophantus of Alexandria (数论)
Diophantus of Alexandria Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java ...
- 【BZOJ-4522】密钥破解 数论 + 模拟 ( Pollard_Rho分解 + Exgcd求逆元 + 快速幂 + 快速乘)
4522: [Cqoi2016]密钥破解 Time Limit: 10 Sec Memory Limit: 512 MBSubmit: 290 Solved: 148[Submit][Status ...
- bzoj2219: 数论之神
#include <iostream> #include <cstdio> #include <cstring> #include <cmath> #i ...
- hdu5072 Coprime (2014鞍山区域赛C题)(数论)
http://acm.hdu.edu.cn/showproblem.php?pid=5072 题意:给出N个数,求有多少个三元组,满足三个数全部两两互质或全部两两不互质. 题解: http://dty ...
- ACM: POJ 1061 青蛙的约会 -数论专题-扩展欧几里德
POJ 1061 青蛙的约会 Time Limit:1000MS Memory Limit:10000KB 64bit IO Format:%lld & %llu Descr ...
- 数论初步(费马小定理) - Happy 2004
Description Consider a positive integer X,and let S be the sum of all positive integer divisors of 2 ...
随机推荐
- parent relation column can't be updated LESSON_EXTENDED_ATTRIBUTE->LESSON_ID
MyCat 中 作为分片的主键不允许更新 , 需要设置为null,调用updateSelectiveByPrimaryKey来更新数据 parent relation column can't be ...
- 垂直居中,水平居中html例子
<!DOCTYPE html> <html lang="en"> <head> <title>Vertical Centering ...
- container 的背后
如果要看laravel的单个功能的源代码,首先去找对应得ServiceProvider,例如加密功能hash,则按一下步骤查看源代码: HashServiceProvider.php(主要是看regi ...
- MySQL通用优化手册
转载: MySQL通用优化手册 内容提纲 MySQL的特点: 硬件.系统优化: MySQL 配置优化: SCHEMA设计优化: SQL 优化: 其他优化. MySQL 的特点 首先,需要明确的是.想要 ...
- IIS提示Server Application Unavailable
浏览器访问网站,IIS提示Server Application Unavailable,我的解决方式是进入IIS管理界面,找到对应的站点,之后重启这个站点.
- HDUOJ------3336 Count the string(kmp)
D - Count the string Time Limit:1000MS Memory Limit:32768KB 64bit IO Format:%I64d & %I64 ...
- Search for a Range [LeetCode]
Given a sorted array of integers, find the starting and ending position of a given target value. You ...
- MyEclipse自动补全与快捷键设置
一般默认情况下,Eclipse ,MyEclipse的代码提示功能是比Microsoft Visual Studio的差很多的,主要是Eclipse ,MyEclipse本身有很多选项是默认关闭的,要 ...
- JDK1.7-LinkedList循环链表优化
最近在看jdk1.7的时候,发现LinkedList 和1.6中的变化. 首先,简单介绍一下LinkedList: LinkedList是List接口的双向链表实现.由于是链表结构,所以长度没有限制: ...
- Java 集合系列 04 LinkedList详细介绍(源码解析)和使用示例
java 集合系列目录: Java 集合系列 01 总体框架 Java 集合系列 02 Collection架构 Java 集合系列 03 ArrayList详细介绍(源码解析)和使用示例 Java ...