POJ 3199 Uncle Jack (高精度)
来源:互联网 发布:身份证验证接口java 编辑:程序博客网 时间:2024/06/10 17:26
Dear Uncle Jack is willing to give away some of his collectable CDs to his nephews. Among the titles you can find very rare albums of Hard Rock, Classical Music, Reggae and much more; each title is considered to be unique. Last week he was listening to one of his favorite songs, Nobody’s fool, and realized that it would be prudent to be aware of the many ways he can give away the CDs among some of his nephews.
So far he has not made up his mind about the total amount of CDs and the number of nephews. Indeed, a given nephew may receive no CDs at all.
Please help dear Uncle Jack, given the total number of CDs and the number of nephews, to calculate the number of different ways to distribute the CDs among the nephews.
The input consists of several test cases. Each test case is given in a single line of the input by, space separated, integers N (1 ≤ N ≤ 10) and D (0 ≤ D ≤ 25), corresponding to the number of nephews and the number of CDs respectively. The end of the test cases is indicated with N = D = 0.
The output consists of several lines, one per test case, following the order given by the input. Each line has the number of all possible ways to distribute D CDs among N nephews.
1 203 100 0
159049【题解】 这就是一个连快速幂题,但是指数范围很小,结果很大,所以就用高精度写,不用快速幂了。
【AC代码】
#include<iostream>#include<stdio.h>#include<map>#include<algorithm>#include<math.h>#include<queue>#include<stack>#include<string>#include<cstring>using namespace std;int t[105],m,n,b[105];void cheng(int a[],int x){ int i,j,w=0; for(i=0;i<=8;i++) t[i]=0; for(i=0;i<=8;i++) { t[i]+=a[i]*x+w; w=t[i]/10000; t[i]%=10000; }}int main(){ int i; while(scanf("%d%d",&m,&n),m||n) { if(!n) { printf("1\n"); continue; } memset(b,0,sizeof(b)); b[0]=m; n--; while(n--) { cheng(b,m); for(i=0;i<=8;i++) b[i]=t[i]; } for(i=8;!b[i];i--); printf("%d",b[i]); i--; for(;i>=0;i--) printf("%04d",b[i]); printf("\n"); } return 0;}
- POJ 3199 Uncle Jack (高精度)
- POJ 3199 Uncle Jack(高精度加速乘)
- POJ 3199 Uncle Jack(JAVA练习)
- POJ 3199 Uncle Jack JAVA .
- POJ 3199 Uncle Jack 笔记
- POJ 3199 Uncle Jack大数的幂 利用高精度乘法模板
- Uncle Jack
- Uncle Jack(大数幂运算java)
- XDOJ1014--Uncle Jack
- poj 1127 Jack Straws(计算几何)
- POJ 1127 Jack Straws (计算几何)
- POJ 1729 Jack ans Jill(bfs)
- POJ 1127(Jack Straws )(线段相交)
- poj 3199 高精度 java
- poj 1001(高精度)
- poj 1001(高精度)
- POJ 1001 求高精度幂(高精度)
- POJ 1127 Jack Straws
- redhat安装jdk
- [Tensorflow][2017-07-25] Demo 运行报错
- 在Mac平台使用GitHub和Hexo搭建博客
- ocp Oracle.1z0-053 711--31
- 学习Lua setmetatable Lua 元表
- POJ 3199 Uncle Jack (高精度)
- 地图-导航(百度/高德)
- 设置通知栏的背景颜色或全幅背景
- 【知识整理】微信小程序-图片在容器中等比缩放至垂直、水平居中,并计算缩放后真实宽高
- hpuoj【1037】一个简单的数学题 【数学】&&【快速幂】
- Spark成长之路(10)-CountVectorizer
- Java遍历Map对象的四种方式
- Spring MVC 入门
- SQL语句大全