例题 小凯的疑惑


小凯的疑惑【Noip2017普及组day1第一题】

先看下题:


 小凯手中有两种面值的金币,两种面值均为正整数且彼此互素。每种金币小凯都有无数个。

在不找零的情况下,仅凭这两种金币,有些物品他是无法准确支付的。现在小凯想知道在无法准确支付的物品中,最贵的价值是多少金币?

注意:输入数据保证存在小凯无法准确支付的商品。

Input

输入数据仅一行,包含两个正整数 a

b

,它们之间用一个空格隔开,表示小凯手中金币的面值。

Output

输出文件仅一行,一个正整数 N

,表示不找零的情况下,小凯用手中的金币不能准确支付的最贵的物品的价值。


上面那道题太水了,我们加强一下


hdu1792 A New Change Problem


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

HINT

A,B<=3*10^9


拿出一张纸,打一个表格,你就会找出规律的,这里给代码【在线处理】


#include
using namespace std;
typedef unsigned long long ull;
ull a,b,c,d;
int main()
{
	while(scanf("%d%d",&a,&b)!=EOF)
	{
		cout<






你可能感兴趣的:(例题 小凯的疑惑)