Home > Back-end >  Where there is a problem for bosses to help see the couple dozen code
Where there is a problem for bosses to help see the couple dozen code

Time:10-30

Topics are as follows:
Title description
Two positive integers m and n, known for its greatest common divisor and least common multiple,

The input and output requirements:
Input of the positive integers m and n, separated by a space between the output of the greatest common divisor and least common multiple, separated by a space between the test cases to ensure m, n and LCM can use int storage,

Program running effect:
Sample 1:
Input: 12 36
Output: 12 36
Sample 2:
Input: 13 7
Output: 91
1My code:
#include
Int main ()
{
Int m, n, min, flag1;
Int Max, tool;
Flag1=1;

The scanf (" % d % d ", & amp; M, & amp; N);
If (n> M)
{
Tool=n;
N=m;
M=tool;
}
Tool=m;
While (flag1==1)
{
If ((tool % m==0) & amp; & (tool % n==0))
{
Max=tool;
Flag1=0;
}
Tool=tool + 1;
}
Flag1=1;
Tool=n;
While (flag1==1)
{
If (% tool (m==0) & amp; & Tool (n %==0))
{
Min=tool;
Flag1=0;
}
Tool=tool - 1;
}
Printf (" % d % d \ n ", min, Max).

return 0;
}
Every submitted show time, where to find for a long time to find the problem by themselves, ask bosses look ORZ

CodePudding user response:

Title description
Problem description:
Known integer a, b, c, your task is to calculate range [a, b] within the integer, satisfy the number and the number of "the all factor (not including itself but including factor and handled as 0, 1, 1) the sum of" the absolute value of the difference between the Numbers less than or equal to c, such as 27,3,9 factor is 1, then with 27 all factor and the difference is: 27 - (1 + 3 + 9)=14,

The input and output requirements:
Enter three integers a, b, c, a, b represent demanding range, meet the 1 & lt;=a<=b<=10000, c represents constraints, c>=0, output meet the conditions of an integer, number for every five line, integer between use TAB delimited, after the last number for line breaks, when no qualified in the area of integers, output "There is no proper number in the interval."

Program running effect:
Sample 1:
Input: 1 10000 0
Output: June 28, 496, 8128
Sample 2:
Input: 2000 5000
Output: 2048 2144 4030 4096
Sample 3:
Input: 900, 1000,
Output: There is no proper number in the interval.
My code:
#include
#include
Int main ()
{
Int a, b, c, ans, i1, i2, d, e, flag, flag1;
I2=c=d=flag=flag1=1;
I1=2;
E=1;

The scanf (" % d % d % d ", & amp; A, & amp; B, & amp; C);
Ans=a;
While (ans<=b)
{
I1=2;
E=1;
If ((ans==1 & amp; & B==1) & amp; & (c!=0))
{ans=ans + 1;
Printf (" 1 ");
Flag1=0; }
If (ans==1)
Ans=ans + 2;
While (i1 & lt; Ans& & Flag1==1)
{
If i1 (ans %==0)
{d=ans/i1;
E=e + d; }
I1=i1 + 1;
}
If (fabs (e - ans) & lt;=c& & Flag1==1)
{
Printf (" % d \ t ", ans);
flag=0;
}
Ans=ans + 1;
}
If (flag==1 & amp; & Flag1==1)
{printf (" There is no proper number in the interval. "); }
Printf (" \ n ");
return 0;
}
This topic every time I submitted shows the answer wrong, cry, tried a lot of examples are no problem ORZ, if free bosses can helping to solve this problem too, please
  • Related