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

因为数据太大了就打表找规律。

import java.util.Scanner;

public class Main {
public static void main(String[] args) { Scanner in = new Scanner(System.in);
int a,b;
while(in.hasNext())
{
a=in.nextInt();
b=in.nextInt();
System.out.println(a*b-a-b+" "+(a-1)*(b-1)/2);
}
in.close();
} }

数学--数论--HDU 1792 A New Change Problem (GCD+打表找规律)的更多相关文章

  1. HDU 5753 Permutation Bo (推导 or 打表找规律)

    Permutation Bo 题目链接: http://acm.hdu.edu.cn/showproblem.php?pid=5753 Description There are two sequen ...

  2. HDU 5795 A Simple Nim(SG打表找规律)

    SG打表找规律 HDU 5795 题目连接 #include<iostream> #include<cstdio> #include<cmath> #include ...

  3. HDU 5795 A Simple Nim (博弈 打表找规律)

    A Simple Nim 题目链接: http://acm.hdu.edu.cn/showproblem.php?pid=5795 Description Two players take turns ...

  4. hdu 1792 A New Change Problem(互质数之间最大不能组合数和不能组合数的个数)

    题意:求互质的m和n的最大不能组合数和不能组合数的个数 思路:m和n的最大不能组合数为m*n-m-n,不能组合数的个数为(m-1)*(n-1)/2 推导: 先讨论最大不能组合数 因为gcd(m,n)= ...

  5. 数学--数论-- HDU -- 2854 Central Meridian Number (暴力打表)

    A Central Meridian (ACM) Number N is a positive integer satisfies that given two positive integers A ...

  6. HDU 4588 Count The Carries 数位DP || 打表找规律

    2013年南京邀请赛的铜牌题...做的非常是伤心.另外有两个不太好想到的地方.. ..a 能够等于零,另外a到b的累加和比較大.大约在2^70左右. 首先说一下解题思路. 首先统计出每一位的1的个数, ...

  7. HDU 3032 Nim or not Nim?(SG打表找规律)

    题意: 给你n堆石子,你每次只能操作一堆石子 1.拿去任意个,最少1个 2.把这一堆分成两堆,没有要求对半分 解析+代码: 1 //解题思路: 2 //对于一个给定的有向无环图,定义关于图的每个顶点的 ...

  8. HDU 4861 Couple doubi (数论 or 打表找规律)

    Couple doubi 题目链接: http://acm.hust.edu.cn/vjudge/contest/121334#problem/D Description DouBiXp has a ...

  9. hdu 3032 Nim or not Nim? (SG函数博弈+打表找规律)

    Nim or not Nim? Time Limit:1000MS     Memory Limit:32768KB     64bit IO Format:%I64d & %I64u Sub ...

随机推荐

  1. uni-app的初识(01)

    1.什么是uni-app uni-app 是一个使用 Vue.js 开发所有前端应用的框架, 开发者编写一套代码, 可发布到IOS, Android, H5, 以及各种小程序(微信,百度)等多个平台. ...

  2. 从零开始实现放置游戏(十三)——实现战斗挂机(4)添加websocket组件

    前两张,我们已经实现了登陆界面和游戏的主界面.不过游戏主界面的数据都是在前端写死的文本,本章我们给game模块添加websocket组件,实现前后端通信,这样,前端的数据就可以从后端动态获取到了. 一 ...

  3. CentOS之crontab

    1.crontab介绍 功能说明:设置计时器. 语 法:crontab [-u <用户名称>][配置文件] 或 crontab [-u <用户名称>][-elr] 补充说明:c ...

  4. Python设计模式(5)-代理模式

    # coding=utf-8 # 代理模式:# * 代理类成为实际想调用对象的中间件,可以控制对实际调用对象的访问权限# * 可以维护实际对象的引用 class DbManager: def __in ...

  5. Java相同id的数据集合,合并数据为一条,并将几个字段内容合并为一个

    Java实现,当然也可以数据库实现; /** * Created by shaozhiqi on 2019/7/31. */ public class TestUnion { @Test public ...

  6. Mybatis对象关系映射 one2one,one2many,many2many

    MyBatis中的高级映射一般要借助select元素中的resultMap属性进行实现,通过此属性配置实现一对一,一对多等关系映射的实现 一对一映射:association 一对多映射:collect ...

  7. for循环in遍历

    <script> //对象本身没有length,所以不能用for循环遍历 //要用for...in...循环 var aaa = {"name":"拴住&qu ...

  8. Nginx+uWSGI+Python+Django构建必应高清壁纸站

    写在前面 做这个网站的初衷是因为,每次打开必应搜索搜东西的时候都会被上面的背景图片吸引,我想必应的壁纸应该是经过专业人员精选出来的,我甚至会翻看以前的历史图片,唯一美中不足的是必应的首页只能查看最多7 ...

  9. golang slice 源码解读

    本文从源码角度学习 golang slice 的创建.扩容,深拷贝的实现. 内部数据结构 slice 仅有三个字段,其中array 是保存数据的部分,len 字段为长度,cap 为容量. type s ...

  10. 数据结构与算法--树(tree)结构

    树 二叉树 遍历原则:前序遍历是根左右, 中序遍历是左根右,后序遍历是左右根. 二叉搜索树 特点:对于树中的每个节点X,它的左子树中所有节点的值都小于X,右子树中所有节点的值都大于X. 遍历:采取二叉 ...