Description
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.
Input
The input will consist of a series of pairs of integers A and B, separated by a space, one pair of integers per line.
Output
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.
Sample Input
2 3
3 4
Sample Output
1 1
5 3
题意
现在给定两种硬币A和B,它们满足GCD(A,B)= 1。在这里,您可以假定这两种硬币都有足够的硬币。请计算您不能支付的最大值和无法支付的总数。
思路
我还是找不到规律,只能打表找。
AC代码
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int a,b;
int n1,n2;
int main()
{
while(cin>>a>>b&&a&&b)
{
n1=a*b-a-b;
n2=(a-1)*(b-1)/2;
cout<<n1<<" "<<n2<<endl;
}
return 0;
}