【组合数】【Lucas】Number Theory Special Training T3 comb 题解
来源:互联网 发布:积分数据库设计 编辑:程序博客网 时间:2024/06/07 02:03
Problem 3. comb
Input file: comb.in
Output file: comb.out
Time limit: 1 second
Memory limit: 256 MB
一天,Mr. Hu 对组合数产生了兴趣,他想要知道满足下面条件的数i 有多少个:
gcd(
(
n
i
)
; p) = p (0 i n)
其中p 是素数。
Input
第1 行,2 个整数:n p。
Output
输出所求。
Sample
comb.in comb.out
5 2 1
Note
样例中,一共有5 个组合数:1; 5; 10; 5; 1,其中和2 公约数为2 的数只有一个10,故输出1。
• 对于30% 的数据,满足1 n; p 103
• 对于100% 的数据,满足1 n; p 1018
Page
#include<iostream>#include<cstdio>#include<cstring>#include<string>#include<set>#include<queue>#include<algorithm>#include<vector>#include<cstdlib>#include<cmath>#include<ctime>#include<stack>#define INF 2100000000#define LL long long#define clr(x) memset(x,0,sizeof(x))#define ms(a,x) memset(x,a,sizeof(x))#ifdef WIN32#define AUTO "%I64d"#else#define AUTO "%lld"#endifusing namespace std;int main() { freopen("comb.in","r",stdin); freopen("comb.out","w",stdout); LL n,p,ans1,ans2; scanf(AUTO""AUTO,&n,&p); ans1 = n+1; ans2 = 1; while(n) ans2 *= n%p+1, n /= p; printf(AUTO"\n",ans1-ans2-1); return 0;}
0 0
- 【组合数】【Lucas】Number Theory Special Training T3 comb 题解
- 【CRT】【组合数】Number Theory Special Training T1 eqution 题解
- 【十进制快速幂】【高精度】Number Theory Special Training T2 power 题解
- 【数学归纳法】【错位排序】Number Theory Special Training T4 derange 题解
- 各种逆元求法 组合数取模 comb (组合数 Lucas)
- 【BZOJ4403】【lucas】【组合数】序列统计 题解
- 【主席树】【线段树】Data Structure Special Training 2 T3 intkth 题解
- 【有序链剖】Data Structure Special Training 1 T3 seqmod 题解
- 【Lucas定理】洛谷1869[愚蠢的组合数]题解
- Lucas求组合数
- 组合数/Lucas定理
- 组合数 (Lucas)
- 2017 UESTC Training for Graph Theory 题解
- 【DP】DP special train T3 粉刷匠2 题解
- 组合数公式&Lucas大组合数
- Lucas大组合数模板
- 组合数中的Lucas定理
- hdu5698 Lucas 大组合数
- c语言复制数组的函数
- Java_util_加密解密字符串
- IM收发消息问题
- java_通过Servlet 将服务器硬盘图片展示到浏览器
- 设置数据库的mysql 使数据库可以用 navicat 访问
- 【组合数】【Lucas】Number Theory Special Training T3 comb 题解
- 历届试题 连号区间数
- 正则表达式匹配不包含某些字符串的技巧
- 树状dp Tree of Tree
- htc_t328w_unlock bootloader
- 洛谷 P1616 疯狂的采药
- linux_各个版本的本地root密码破解方法
- 使用tmux分屏(既可以左右分屏,也可以上下分屏)
- linux_六点安全方法应用