The proof is here, and it's very well written.
2662 Coin
Time limit:2000/1000 MS (java/others) Memory limit:32768/32768 K (java/others)
Total Submission (s): 903 Accepted Submission (s): 437
problem DescriptionMoon have many coins, but only contains-value types which is 5 cents and 7 cents, Some Day he find-he can get any Value which greater than cents using some of his coins. For instance, he can get cents using the 5 cents coins and 7 cents coins, he can get cents using five 5 cents Co Ins, he can get the cents using one 5 cents coins and three 7 cents coins and so on.
Now, give many coins which just contains-value types just like Moon, and the both value types identified by both dif Ferent prime number I and J. Can you caculate the integer n, the any value greater than n can is created by some of the given coins. InputThe first line contains an integer T, indicates the number of test cases.
For each test case, there is different prime I and J separated by a single space. (2<=i<=1000000, 2<=j<=1000000) Outputfor each test case, output one line contains the number n adapt the problem description.
Sample Input
1 5 7
Sample Output
23
SourceHDU Boys ' special open--before the girls get a holiday (from WHU)
Title Link: http://acm.hdu.edu.cn/showproblem.php?pid=2662
To the number of two coprime, the maximum number that cannot be composed by the infinite
Title Analysis: When the theorem is written, ans = n * m-n-M
#include <cstdio> #define LL long Longint 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 DescriptionNow given, kinds of coins A and B,which satisfy that GCD (A, B) =1.here you can assume that there is enough coins for Both kinds. Please calculate the maximal value , the cannot pay, and the total number, that's cannot pay. InputThe input would consist of a series of pairs of integers a and B, separated by a space, one pair of integers per line.
OutputFor each pair of input integers A and B you should output the the the maximal value that's cannot pay and the total numb Er that you cannot pay, and with a line of output for each line in input. Sample Input
2 33 4
Sample Output
1 15 3
Title Link: http://acm.hdu.edu.cn/showproblem.php?pid=1792
The main idea: to give two coprime of the number, to use the infinite they can not be composed of the largest number and the number of numbers cannot be composed
Title Analysis: When the theorem is written, it cannot be composed of the largest number n * m-n-M, cannot be composed of the number (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);}
Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.
HDU 2662 Coin && HDU 1792 A New change problem (Inma maximum cannot generate number)