Problem description
Xiao Ming opened a candy shop. His ingenuity: to pack the fruit candy into 4 packs and 7 packs of two. Sweets cannot be sold by unpacking.
When the children came to buy the sugar, he used the two kinds of packaging to combine. Of course, some of the number of sweets can not be combined, such as to buy 10 sugar.
You can test it with a computer, in which case the maximum quantity that cannot be bought is 17. Any number greater than 17 can be combined with 4 and 7.
The requirement of the subject is to find the maximum number of characters that cannot be combined when the quantity of two packages is known.
Input format
Two positive integers representing the number of sugars in each package (no more than 1000)
Output format
A positive integer representing the maximum number of sugars that cannot be bought
Sample Input 14 7
Sample output 117 Sample input 23 5
Sample Output 2
7
Number theory: Two coprime, the largest integer that cannot be combined is n (m-1)-m, number of integers that cannot be combined (n-1) * (m-1)/2
#include <iostream> #include <cstdio>using namespace Std;int main () { int n,m; while (scanf ("%d%d", &n,&m)!=eof) { printf ("%d\n", n*m-n-m); } return 0;}
The number that can't be bought