福大程序在线评测系统 Problem 1992 An Easy Problem 怎么解?In mathematics, “MOD” operation is common. C = A (MOD B), which means that the remainder of A after divided by B is equal to that of C. It’s an easy problem to test whether A
来源:学生作业帮助网 编辑:作业帮 时间:2024/11/07 21:32:21
福大程序在线评测系统 Problem 1992 An Easy Problem 怎么解?In mathematics, “MOD” operation is common. C = A (MOD B), which means that the remainder of A after divided by B is equal to that of C. It’s an easy problem to test whether A
福大程序在线评测系统 Problem 1992 An Easy Problem 怎么解?
In mathematics, “MOD” operation is common. C = A (MOD B), which means that the
remainder of A after divided by B is equal to that of C. It’s an easy problem to
test whether A and C satisfy the condition above. But what you are expected to
is not so easy! You will be given A and C and to find the number of B who
satisfies the condition (equation) above, you could assume that A is not equal
to C in this problem.
输入
A=9,C=3
为什么结果是B=4
问题网址链接:http://acm.fzu.edu.cn/problem.php?pid=1992
福大程序在线评测系统 Problem 1992 An Easy Problem 怎么解?In mathematics, “MOD” operation is common. C = A (MOD B), which means that the remainder of A after divided by B is equal to that of C. It’s an easy problem to test whether A
解法也很简单,因为模b余数相同,则可以设a = k1 * b + d,c = k2 * b + d a-c = (k1-k2)*b; 所以b是(a-c)的一个因数,答案就是(a-c)的因子数;
#include
#include
#include
using namespace std;
int main()
{
int a,c,total,t,tmp,cs = 0;
scanf("%d",&t);
while( t-- )
{
total = 0;
scanf("%d%d",&a,&c);
tmp = a > c a-c :c - a;
for(int i=1;i*i