poj 3199 Uncle Jack
2011-11-23 10:01
330 查看
Uncle Jack
Description
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.
Input
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.
Output
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.
Sample Input
Sample Output
Time Limit: 1000MS | Memory Limit: 65536K | |
Total Submissions: 3744 | Accepted: 1565 |
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.
Input
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.
Output
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.
Sample Input
1 20 3 10 0 0
Sample Output
1 59049
#include<stdio.h> #include<iostream> using namespace std; __int64 mod=10000000,temp1,temp2,temp; __int64 multi(__int64 n,__int64 d) { temp1=0,temp2=n; __int64 i,c; for(i=2;i<=d;i++) { temp=temp2*n; c=temp/mod; temp2=temp%mod; temp1=(temp1*n)+c; } return 0; } int main() { __int64 n,d; mod*=mod; while(scanf("%I64d%I64d",&n,&d),n+d) { multi(n,d); if(d==0) printf("1\n"); else if(temp1) printf("%I64d%.14I64d\n",temp1,temp2); else printf("%I64d\n",temp2); } return 0; }
相关文章推荐
- POJ 3199 Uncle Jack(高精度加速乘)
- POJ 3199 Uncle Jack 笔记
- POJ 3199 Uncle Jack大数的幂 利用高精度乘法模板
- POJ 3199 Uncle Jack (高精度)
- POJ 3199 Uncle Jack大数的幂 利用高精度乘法模板
- POJ 3199 Uncle Jack(JAVA练习)
- poj 3199 高精度 java
- POJ 2196 & ZOJ 2405 & UVA 3199
- EOJ 3199/POJ 1258 Agri-Net【Prim】
- POJ 2545 && HDU 3199 Hamming Problem(数论)
- 【Java练习11】POJ 3199
- POJ 3199 Uncle Jack JAVA .
- poj1027——The Same Game
- 【线段树 + 详细注释】北大 poj 3264 Balanced Lineup
- poj 2127 Greatest Common Increasing Subsequence
- poj 1080 最长公共子串变形
- poj2240--floyd算法
- poj 1503 大数...java真强大...
- POJ 2503 Babelfish
- POJ刷题指南