数学--数论--HDU1792A New Change Problem(GCD规律推导)
A New Change Problem
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();
}
}
数学--数论--HDU1792A New Change Problem(GCD规律推导)的更多相关文章
- HDU1792A New Change Problem(GCD规律推导)
A New Change Problem Time Limit: 5000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Oth ...
- 数学--数论--HDU - 6322 打表找规律
In number theory, Euler's totient function φ(n) counts the positive integers up to a given integer n ...
- 数学--数论--HDU 5019 revenge of GCD
Revenge of GCD Problem Description In mathematics, the greatest common divisor (gcd), also known as ...
- 数学--数论--HDU 2197 本原串 (推规律)
由0和1组成的串中,不能表示为由几个相同的较小的串连接成的串,称为本原串,有多少个长为n(n<=100000000)的本原串? 答案mod2008. 例如,100100不是本原串,因为他是由两个 ...
- UVA 1363 Joseph's Problem 找规律+推导 给定n,k;求k%[1,n]的和。
/** 题目:Joseph's Problem 链接:https://vjudge.net/problem/UVA-1363 题意:给定n,k;求k%[1,n]的和. 思路: 没想出来,看了lrj的想 ...
- 365. Water and Jug Problem (GCD or BFS) TBC
https://leetcode.com/problems/water-and-jug-problem/description/ -- 365 There are two methods to sol ...
- HDU 2086 A1 = ? (找规律推导公式 + 水题)(Java版)
Equations 题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=2086 ——每天在线,欢迎留言谈论. 题目大意: 有如下方程:Ai = (Ai-1 ...
- 数学--数论--HDU 1792 A New Change Problem (GCD+打表找规律)
Problem Description Now given two kinds of coins A and B,which satisfy that GCD(A,B)=1.Here you can ...
- 数学--数论--HDU 4675 GCD of Sequence(莫比乌斯反演+卢卡斯定理求组合数+乘法逆元+快速幂取模)
先放知识点: 莫比乌斯反演 卢卡斯定理求组合数 乘法逆元 快速幂取模 GCD of Sequence Alice is playing a game with Bob. Alice shows N i ...
随机推荐
- 10.2 io流 之字节流和字符流
FileWriter 用于写入字符流.要写入原始字节流,请考虑使用 FileOutputStream. io流相关文档: https://www.cnblogs.com/albertrui/p/836 ...
- json === dict
import requests import json ''' json.loads(json_str) json字符串转换成字典 json.dumps(dict) 字典转换成json字符串 ''' ...
- Daily Scrum 1/12/2016
Zhaoyang & Yandong: Optimize the speech input interface Fuchen: Code refactor in the NLP module ...
- vue-cli目录结构分析
vue3初始化一个项目,查看其项目结构,会发现比vue2的更加简洁. package.json说明 项目的配置文件,定义了项目的基本信息以及项目的相关包依赖,npm运行命令等,位于项目根目录. scr ...
- javascript实例教程使用canvas技术模仿echarts柱状图
canvas 画布是HTML5中新增的标签,可以通过js操作 canvas 绘图 API在网页中绘制图像. 百度开发了一个开源的可视化图表库ECharts,功能非常强大,可以实现折线图.柱状图.散点图 ...
- 详解PHP反序列化中的字符逃逸
首发先知社区,https://xz.aliyun.com/t/6718/ PHP 反序列化字符逃逸 下述所有测试均在 php 7.1.13 nts 下完成 先说几个特性,PHP 在反序列化时,对类中不 ...
- C++写日志方法调试
调试方法有很多 介绍一种奇怪的?调试方法哈哈 通过WriteLog记录返回值查看返回结果. string str_log;stringstream ssteam;ssteam << &qu ...
- redis: Jedis API(十四)
1.Key操作 package com.kuang; import redis.clients.jedis.Jedis; import java.util.Set; public class Test ...
- SMTP发邮件(直接可用)实例
string file = "邮件测试.txt";//放在Debug下的一个txt文件. MailAddress from = new MailAddress("自己的邮 ...
- tensorflow1.0 构建卷积神经网络
import tensorflow as tf from tensorflow.examples.tutorials.mnist import input_data import os os.envi ...