AB calculator and program

xiaoxiao2021-04-08  399

AB

Calculator

Program file name

: ab.cpp / ab.pas / ...

South

ACM

One of the veteran of the association designed a special calculator. This calculator has only four keys

(A, b, , -)

.

The value displayed by the calculator begins to

c

,

click it once

" "

Then press it.

"A"

, Increase the value displayed by the calculator

a

click it once

"-"

Then press it.

"A"

Reduce the value displayed by the calculator

a

click it once

" "

Then press it.

"B"

, Increase the value displayed by the calculator

b

click it once

"-"

Then press it.

"B"

Reduce the value displayed by the calculator

B

I need to need to press at least

A

The key can make the value displayed by the calculator as

0

enter

(Please use standard input and output, not to read and write)

Enter the three positive integers

a

,

B

,

c

, Separated by space, satisfaction

0

,

0

,

0

,

a

,

B

Respectively

A

Key and

B

Corresponding value of the key,

c

Indicates the initial value displayed by the calculator.

(2 ^ 95

Indicate

2

of

95

Power

)

Output

(Please use standard input and output, not to read and write)

There is only one number, ie

A

The minimum of the number of keys is pressed

(

We ensure that the entered situation has corresponding answers

)

Sample input

1

Sample output

1

7 12 8

4

Sample input

2

Sample output

2

10549830 6549835 5

140969

#include #include #include // # include #include "math.h"

Void main () {Double A, B, C; INT j = 0; INT DI = 0, DJ; INT i = 0; BOOL ACC = FALSE; BOOL ACC = FALSE; Double Temp; Bool Flag = False; int Times = 1000000; cout << "Input three digital ABC:" << endl; cin >> a >> b >> C; for (i = 0; i <100000 &&! Flag; i ) /// {for ( J = 0; j <100000 &&! flag; j ) {IF ((i * a j * b) == c) {TIMES = i; di = i; dj = j; flag = true;} IF ((i * a j * b)> c) Break;} if (i * a> c) Break;} flag = false; cout << "2 ================= ============ "<< endl; for (i = 0; I -300000 &&! flag; j--) {= ((Temp J * B)> C &&! ACC) // jiasu ACC {J = J-3000; Continue;} else if ACC) {ACC = true; j = j 3000;} IF ((Temp J * B)> C &&! ACCC) // Accelerates ACCC {J = J-600; Continue;} else if (! acid) {acid = True; j = j 600;}

IF ((Temp J * B) == C) f (i -times &&! flag; i -) // - {ACC = false; acid = false; temp = i * a; for (j = 0; j <1000000 &&! flag; j ) {IF ((Temp J * b) c) Break;} IF ((TIMES / 100)! = 0) IF ( (-i)% (TIMES / 100) == 99) cout << (- i) * 100 / Times << "%" << endl;} cout << "Enter the fourth algorithm" << endl; for (i = 0; i> -times &&! flag; i -) // - - {TEMP = i * a; ACC = FALSE For (j = 0; j> -times &&! flag; j -) {if ((Temp J * b)> C &&! ACC) {J = J-3000; Continue;} else if (! ACC) {ACC = True; j = j 3000;}


New Post(0)