2013
12-23

# A New Change Problem

Now given two kinds of coins A and B,which satisfy that GCD(A,B)=1.Here you can assume that there are enough coins for both kinds.Please calculate the maximal value that you cannot pay and the total number that you cannot pay.

The input will consist of a series of pairs of integers A and B, separated by a space, one pair of integers per line.

For each pair of input integers A and B you should output the the maximal value that you cannot pay and the total number that you cannot pay, and with one line of output for each line in input.

2 3
3 4

1 1
5 3

A*x+B*y（x>=0,y>=0)

#include<stdio.h>
int main()
{
int A,B;
while(scanf("%d%d",&A,&B)!=EOF)
{
printf("%d %d\n",A*B-A-B,(A-1)*(B-1)/2);
}
return 0;
}

1. 换句话说，A[k/2-1]不可能大于两数组合并之后的第k小值，所以我们可以将其抛弃。
应该是，不可能小于合并后的第K小值吧

2. 学算法中的数据结构学到一定程度会乐此不疲的，比如其中的2－3树，类似的红黑树，我甚至可以自己写个逻辑文件系统结构来。