HDU男生专场公开赛——赶在女生之前先过节(From
WHU)
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=2662
题目大意:给两个互质的数,求用无限个它们不能组成的最大的数
题目分析:当定理记吧,ans = n * m - n - m
#include <cstdio>
#define ll long long
int main()
{
int T;
scanf("%d", &T);
while(T--)
{
ll a, b;
scanf("%I64d %I64d", &a, &b);
printf("%lld\n", a * b - a - b);
}
}
1792 A New Change Problem
Time Limit: 5000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 936 Accepted Submission(s): 515
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
Sample Output
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1792
题目大意:给两个互质的数,求用无限个它们不能组成的最大的数和不能组成的数的个数
题目分析:当定理记吧,不能组成的最大数n * m - n - m,不能组成的个数(n - 1) * (m - 1) / 2
#include <cstdio>
int main()
{
int a, b;
while(scanf("%d %d", &a, &b) != EOF)
printf("%d %d\n", a * b - a - b, (a - 1) * (b - 1) / 2);
}