How does you add?
Larry is very bad at Math-he usually uses a calculator, which
worked well throughout college. Unforunately, he is now struck in
A deserted and his good buddy Ryan after a snowboarding
Accident.
They ' re now trying to spend some time figuring out some good
Problems, and Ryan would eat Larry if he cannot answer, so he fate
is up to you!
It's a very simple problem-given a number N, how many ways
Can K numbers less than n add up to n?
For example, for N = 2 and K = +, there is ways:
0+20
1+19
2+18
3+17
4+16
5+15
...
18+2
19+1
20+0
Input
Each line would contain a pair of numbers n and K. N and K would both is an integer from 1 to 100,
Inclusive. The input would terminate on 2 0 ' s.
Output
Since Larry is only interested in the last few digits of the answer, for each pair of numbers N and K,
Print a single number mod 1,000,000 to a single line.
Sample Input
20 2
20 2
0 0
Sample Output
21st
21st
Map[I][j]=Map[I-1][j]+map[i][j-1];
1#include <iostream>2#include <cstdio>3#include <cstring>4 5 using namespacestd;6 intMain ()7 {8 intmap[ the][ the];9 intK;Tenmemset (Map,0,sizeof(map)); One for(intI=1;i<101; i++) A { -map[i][1]=1; -map[1][i]=i; the } - for(intI=2;i<101; i++) - { - for(intj=2;j<101; j + +) + { -map[i][j]=map[i-1][j]+map[i][j-1]; + if(map[i][j]>1000000) Amap[i][j]%=1000000; at } - } - intb; - while(cin>>a>>b) - { - if(a==0&&b==0) in Break; -cout<<map[a][b]<<Endl; to } + return 0; -}
UVA 10943 How does you add?