UVA 10943 How does you add?

Source: Internet
Author: User

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?

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.