Uncle Jack
来源:互联网 发布:excel 两列数据除法 编辑:程序博客网 时间:2024/06/01 19:36
Uncle Jack
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 203 100 0
Output for the sample input
159049
code:
#include<iostream>using namespace std;int main(){int m,n,s,t,a[28],k;while(cin>>m>>n){if(m==0&&n==0)break;if(m==10){cout<<"1";for(int i=0;i<n;i++)cout<<"0";cout<<endl;continue;}if(n==0){cout<<"1"<<endl;continue;}for(int i=0;i<27;i++)a[i]=0;a[26]=1;s=0;for(int j=0;j<n;j++){t=0;for(int i=26;i>=0;i--){s=a[i]*m+t;a[i]=s%10;t=s/10;}}for(k=0;k<27,a[k]==0;k++);for(;k<27;k++)cout<<a[k];cout<<endl;}return 0;}
- Uncle Jack
- XDOJ1014--Uncle Jack
- POJ 3199 Uncle Jack JAVA .
- POJ 3199 Uncle Jack 笔记
- POJ 3199 Uncle Jack(JAVA练习)
- Uncle Jack(大数幂运算java)
- POJ 3199 Uncle Jack (高精度)
- POJ 3199 Uncle Jack(高精度加速乘)
- POJ 3199 Uncle Jack大数的幂 利用高精度乘法模板
- Jack
- jack
- uncle bob
- Uncle Hey
- Uncle Hey
- Uncle Hey
- Uncle Hey
- Uncle Hey
- Uncle Hey
- C++全局作用域与全局变量(V2.0)
- 设计模式入门之备忘录模式Memento
- MongoDB_05之查询
- [Android学习笔记[使用Fragments取代tabActivity开发网易新闻客户端框架
- cocos2dx 3.0 找不到资源导致黑屏(用cocos new 创建的default工程一定要记得修改工作目录的配置)
- Uncle Jack
- 关于Mac系统下某些Android设备无法被adb识别问题的解决方法
- Python - 继承object类
- x & (x - 1)==0
- 数据库架构的演变
- ORACLE11G64位win7完美安装图解及问题解决
- 关于无法找到 ruby/config.h
- POJ 2823 单调队列
- c++引用深入探讨