HDU 1792 A New Change Problem
題目描述
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.
(譯文:已知兩種硬幣A和B,滿足GCD(A,B)=1。這裡你可以假設兩種硬幣都有足夠的硬幣。請計算您無法支付的最大值和您無法支付的總數)
輸入
The input will consist of a series of pairs of integers A and B, separated by a space, one pair of integers per line.
(譯文:輸入將由一系列的整數對a和B組成,由一個空格分隔,每行一對整數。)
輸出
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.
(譯文:對於每對輸入整數A和B,應該輸出不能支付的最大值和不能支付的總數,並且輸入中的每一行都有一行輸出。)
樣例:
輸入:
2 3
3 4
輸出:
1 1
5 3
題解:(找規律)
程式碼:
#include<stdio.h>
int main()
{
int A,B;
while(scanf("%d%d",&A,&B)!=EOF)
{
int m=A*B-A-B;
int n=(A-1)*(B-1)/2;
printf("%d %d\n",m,n);
}
return 0;
}
相關文章
- Hdu 1792 A New Change Problem 結論
- HDU 1792 - A New Change Problem(規律,最大不能組合數及其個數)
- 【HDU - 1792】A New Change Problem(推公式、互質數的最大不能表示數)公式
- HDU - 6182 A Math Problem
- change ^M to new line
- HDU 1002 A + B Problem II
- HDU 2256Problem of Precision(矩陣快速冪)矩陣
- [DP]HDU6415(2018多校訓練賽第九場 Problem A) Rikka with Nash Equilibrium 題解UI
- sqlserver Change Data Capture&Change TrackingSQLServerAPT
- HDU-1792-( 兩個互質的數線性組合最大不能表示的數和不能表示數的個數)
- 論文閱讀:A new approach solve the multi-product multi-period inventory lot sizing with supplier selection problemAPP
- Sum Problem
- Mathematical Problem
- HDU - 6003 Problem Buyer題解(貪心選擇演算法,鴿巢原理,優先佇列維護)演算法佇列
- hdu 2111 Saving HDU (DP)
- JavaScript change 事件JavaScript事件
- Madagascar Projection ChangeProject
- Prime Ring Problem
- 2019 MCM Problem A
- Yet Another Problem
- Nanami and the Constructive ProblemNaNStruct
- new self()與new static()
- chmod命令(change mode)
- 322. Coin Change
- change tabs in Adobe AcrobatBAT
- New
- Fixed "There was a problem with the editor 'vi'"
- Prime Ring Problem (dfs)
- Problem A. Ascending Rating
- E. Not a Nim Problem
- Nanami and the House Protecting ProblemNaN
- Shape of HDU
- HDU 3349
- [20190312]檢視v$datafile欄位OFFLINE_CHANGE#, ONLINE_CHANGE#.txt
- HDU 2052(C語言+註釋)+HDU 2090C語言
- JavaScript中的new map()和new set()使用詳細(new map()和new set()的區別)JavaScript
- How to change the background color for PyCharmPyCharm
- gerrit "missing Change-Id"