HDU 1792 A New Change Problem(数学规律题,数论知识)
2012-04-05 22:48
519 查看
A New Change Problem
Time Limit: 5000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 533 Accepted Submission(s): 265
[align=left]Problem Description[/align]
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.
[align=left]Input[/align]
The input will consist of a series of pairs of integers A and B, separated by a space, one pair of integers per line.
[align=left]Output[/align]
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.
[align=left]Sample Input[/align]
2 3 3 4
[align=left]Sample Output[/align]
1 1 5 3
[align=left]Author[/align]
lcy
[align=left]Recommend[/align]
lcy
题目就是给了两个互质的数A,B。
A*x+B*y(x>=0,y>=0)
问最大不能表示的数,和不能表示的数的个数。
数论知识;
个数就是(A-1)*(B-1)/2;
最大不能表示的数就是 A*B-A-B;
所有的数可以分成A类,就是对A取模余0~A-1的。
·······
简要推导见:http://hi.baidu.com/qq258513813/blog/item/81c1d5c57e9ac7009d163da6.html
代码:
#include<stdio.h> 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); } return 0; }
相关文章推荐
- 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 剩余系
- HDOJ 1792 A New Change Problem (数论)
- hdu 5109 Alexandra and A*B Problem(取模,枚举,数学数论)
- bfs+队列 数学规律 HDU Problem Q
- 数论基础定理及其应用(hdu 2685 I won't tell you this is about number theory, hdu 2582 f(n),hdu 1792 A New Chan)
- 数学规律题,数论知识:hdu1792
- hdu 5373 The shortest problem(模拟、数学规律)
- HDU 4569Special equations2012长沙邀请赛E题(数学知识)
- test 7 Problem A: [noip2016十连测第七场]约瑟夫游戏 (找规律+数论)
- ACM: 数学规律题 数论题 hdoj 1021
- HDU(1273)——漫步森林(数学的找规律题)
- HDU 1695 GCD (数论-整数和素数,组合数学-容斥原理)
- A New Change Problem
- hdu 2277 Change the ball(找规律)
- hdu 4910 Problem about GCD 找规律+Miller_Rabin算法+线性筛
- hdu - 2058 The sum problem (数学题)