Hdu 1792 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
題意:
求兩個互質數的最大不能組成的數和不能組成的數的個數....
網上找的公式.....
最大不能組成的數為a*b-a-b;
不能組成的數為(a-1)*(b-1)/2;
程式碼如下:
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <iostream>
using namespace std;
int a,b;
int main()
{
while (scanf("%d%d",&a,&b)!=EOF)
{
printf("%d %d\n",a*b-a-b,(a-1)*(b-1)/2);
}
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(矩陣快速冪)矩陣
- 論文閱讀:A new approach solve the multi-product multi-period inventory lot sizing with supplier selection problemAPP
- mysql change buffer小結MySql
- 【博弈論】HDU - 7216 Triangle GameGAM
- HDU 1060 Leftmost Digit(數論,c++)GitC++
- [DP]HDU6415(2018多校訓練賽第九場 Problem A) Rikka with Nash Equilibrium 題解UI
- sqlserver Change Data Capture&Change TrackingSQLServerAPT
- HDU-1792-( 兩個互質的數線性組合最大不能表示的數和不能表示數的個數)
- HDU 6058 Kanade's sum(連結串列)
- Sum Problem
- Mathematical Problem
- HDU - 6003 Problem Buyer題解(貪心選擇演算法,鴿巢原理,優先佇列維護)演算法佇列
- hdu 2111 Saving HDU (DP)
- JavaScript change 事件JavaScript事件
- Madagascar Projection ChangeProject
- 論文解讀《Measuring and Relieving the Over-smoothing Problem for Graph NeuralNetworks from the Topological View》View
- 論文翻譯五:A New Method of Automatic Modulation Recognition Based on Dimension Reduction
- 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
- python中的__init__ 、__new__、__call__小結Python