前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >数学--数论--HDU 1792 A New Change Problem (GCD+打表找规律)

数学--数论--HDU 1792 A New Change Problem (GCD+打表找规律)

作者头像
风骨散人Chiam
发布2020-11-06 00:46:25
3020
发布2020-11-06 00:46:25
举报
文章被收录于专栏:CSDN旧文CSDN旧文

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

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

代码语言:javascript
复制
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();
	}

}
本文参与 腾讯云自媒体分享计划,分享自作者个人站点/博客。
原始发表:2019-12-17 ,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体分享计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档