博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
HDU1133 Buy the Ticket
阅读量:4136 次
发布时间:2019-05-25

本文共 1913 字,大约阅读时间需要 6 分钟。

Problem Description
The "Harry Potter and the Goblet of Fire" will be on show in the next few days. As a crazy fan of Harry Potter, you will go to the cinema and have the first sight, won’t you?
Suppose the cinema only has one ticket-office and the price for per-ticket is 50 dollars. The queue for buying the tickets is consisted of m + n persons (m persons each only has the 50-dollar bill and n persons each only has the 100-dollar bill).
Now the problem for you is to calculate the number of different ways of the queue that the buying process won't be stopped from the first person till the last person. 
Note: initially the ticket-office has no money. 
The buying process will be stopped on the occasion that the ticket-office has no 50-dollar bill but the first person of the queue only has the 100-dollar bill.
 

Input
The input file contains several test cases. Each test case is made up of two integer numbers: m and n. It is terminated by m = n = 0. Otherwise, m, n <=100.
 

Output
For each test case, first print the test number (counting from 1) in one line, then output the number of different ways in another line.
 

Sample Input
3 03 13 30 0
 

Sample Output
Test #1:6Test #2:18Test #3:180

大数运算:

#include 
using namespace std;#include
const int N=400;char store [203][N];//整数n转化为字符串svoid itos(int n,char *s){ int i,j,t[5]; if(n==0){ s[0]='0'; s[1]=0; return; } i=0; while(n){ t[i++]=n%10; n/=10; } i--; j=0; while(i>=0) s[j++]=t[i--]+'0'; s[j]=0;}//计算m*c=res.默认m和c不为0void mul(char *m,char *c,char *res){ int i,j,len1,len2; len1=strlen(m),len2=strlen(c); int *r=new int[len1+len2+1]; for(i=0;i<=len1+len2;i++) r[i]=0; for(i=0;i
=1;i--)//处理进位 if(r[i]>9){ int tmp=r[i]/10; r[i]%=10; r[i-1]+=tmp; } for(i=0;i
1){ itos(n,s); mul(res,s,t); strcpy(res,t); }}//小数d去除大数mvoid div(char *m,int d,char *res){ int i,len; int r,tmp; len=strlen(m); r=0;//余数 for(i=0;i

转载地址:http://jdvvi.baihongyu.com/

你可能感兴趣的文章