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 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(公式)公式
- Training - Problem and Change ManagementAI
- change ^M to new line
- HDU5293 : Tree chain problemAI
- 數學規律題,數論知識:hdu1792
- Credit limit change request and new enterprise serviceMIT
- HDU 2256Problem of Precision(矩陣快速冪)矩陣
- HDU 4291 A Short problem(矩陣快速冪+迴圈節)矩陣
- Problem_2 Majority Problem
- Mathematical Problem
- sqlserver Change Data Capture&Change TrackingSQLServerAPT
- 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
- New start new hope!
- 論文閱讀:A new approach solve the multi-product multi-period inventory lot sizing with supplier selection problemAPP
- Fixed "There was a problem with the editor 'vi'"
- STL iterator delete problemdelete
- E. Not a Nim Problem
- new self()與new static()
- new Child();new Child(1);
- chmod命令(change mode)
- Change redhat root passwordRedhat