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 1792 A New Change Problem 剩餘系
- HDU 2662 Coin && HDU 1792 A New Change Problem (互質數最大不能生成數)
- HDU 1792-A New Change Problem(互質數的最大不能表示數)
- 【HDU - 1792】A New Change Problem(推公式、互質數的最大不能表示數)公式
- HDU 1792 - A New Change Problem(規律,最大不能組合數及其個數)
- HDU1792(公式)公式
- 數學規律題,數論知識:hdu1792
- Training - Problem and Change ManagementAI
- change ^M to new line
- HDU5293 : Tree chain problemAI
- Credit limit change request and new enterprise serviceMIT
- HDU 2256Problem of Precision(矩陣快速冪)矩陣
- HDU 4291 A Short problem(矩陣快速冪+迴圈節)矩陣
- mysql change buffer小結MySql
- 論文閱讀:A new approach solve the multi-product multi-period inventory lot sizing with supplier selection problemAPP
- HDU 4940 Destroy Transportation system(圖論)圖論
- HDU 2254 奧運(數論+矩陣)矩陣
- 【博弈論】HDU - 7216 Triangle GameGAM
- HDU 4279 2012網路賽Number(數論 尤拉函式結論約數個數)函式
- Problem_2 Majority Problem
- Mathematical Problem
- sqlserver Change Data Capture&Change TrackingSQLServerAPT
- HDU 1060 Leftmost Digit(數論,c++)GitC++
- hdu Yet another end of the world(擴充套件歐幾里得定理推論)套件
- “new” 都做了些啥以及this繫結?
- FZU Problem 1692 Key problem(迴圈矩陣)矩陣
- HDU - 6003 Problem Buyer題解(貪心選擇演算法,鴿巢原理,優先佇列維護)演算法佇列
- ACM A problem is easyACM
- Database Transaction ProblemDatabase
- Yet Another Problem
- JavaScript change 事件JavaScript事件
- js change 事件JS事件
- jQuery change事件jQuery事件
- Change domain timeAI
- Who is the Last Change?AST