hdu 1792 A New Change Problem(數論)
A New Change Problem
Time Limit: 5000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 1236 Accepted Submission(s): 737
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-1)*b-a,不能組合數的個數為(a-1)*(b-1)/2
程式碼:
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>
using namespace std;
int main()
{
int n,m;
while(~scanf("%d %d",&m,&n))
{
printf("%d %d\n",(m-1)*n-m,(n-1)*(m-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
- HDU 2254 奧運(數論+矩陣)矩陣
- Credit limit change request and new enterprise serviceMIT
- HDU 2256Problem of Precision(矩陣快速冪)矩陣
- HDU 4291 A Short problem(矩陣快速冪+迴圈節)矩陣
- HDU 4279 2012網路賽Number(數論 尤拉函式結論約數個數)函式
- HDU 1060 Leftmost Digit(數論,c++)GitC++
- 論文閱讀:A new approach solve the multi-product multi-period inventory lot sizing with supplier selection problemAPP
- HDU 4940 Destroy Transportation system(圖論)圖論
- 【博弈論】HDU - 7216 Triangle GameGAM
- Problem_2 Majority Problem
- 數論——數論分塊
- HDU 2685 I won't tell you this is about number theory (數論 公式 快速冪取模)公式
- hdu 2097 Java Sky數Java
- hdu 2072 Java 單詞數(超級坑) HDU 2072Java
- 數論
- Mathematical Problem
- HDU 4944 FSF’s game(計數遊戲)GAM遊戲
- HDU 4497GCD and LCM(素數分解)GC
- sqlserver Change Data Capture&Change TrackingSQLServerAPT
- element-UI change 事件傳遞自定義引數UI事件
- hdu Yet another end of the world(擴充套件歐幾里得定理推論)套件
- hdu5435 數位dp(大數的處理)
- FZU Problem 1692 Key problem(迴圈矩陣)矩陣
- codeforces 340CTourist Problem(找規律數學題)
- 【KMP求字串匹配次數】 hdu 1686KMP字串匹配