## Algorithm

Problem Name: 2 AD-HOC - beecrowd | 1542

By Normandes Jr, UFU Brazil

Timelimit: 3

You've started competing against your friend to see who can read more books in less time. Your friend used to read much more fast than you, until the day you realized that he'd read only small books.

So, you've decided counting how many pages each book has. And decided to increase the amount of pages read per day. Now you read 5 pages per day and finish 16 days before, if you were reading 3 pages per day. In this case, how many pages has the book?

## Input

The input has many test cases. Each test has tree numbers Q (0 < Q < 20), D (0 < D < 20) and P (0 < P < 20) separated by one blank space. Q means the amount of pages read per day. D is the number of days you could speed up, if you were reading the amount of pages P. An unique 0 (zero) value means end of inputs.

## Output

For each test case it should be printed how many pages the book has. Use plural appropriately in Portuguese ("pagina" or "paginas"). This number should be an integer and truncated - no rounding.

 Sample Input Sample Output 3 16 5 0 120 paginas

## Code Examples

### #1 Code Example with C Programming

```Code - C Programming```

``````
#include <stdio.h>

int main(void) {
int A, B, C, N;

while (scanf("%d", &A) && A != 0) {
scanf("%d %d", &B, &C);
N = (int)((A * B * C) / (C - A));
if (N == 1) printf("1 pagina\n");
else printf("%d paginas\n", N);
}

return 0;
}
``````
Copy The Code &

Input

cmd
3 16 5
0

Output

cmd
120 paginas

### #2 Code Example with C++ Programming

```Code - C++ Programming```

``````
#include <iostream>

using namespace std;

int main(void) {
int A, B, C, N;

while (cin >> A && A != 0) {
cin >> B >> C;
N = int((A * B * C) / (C - A));
if (N == 1) cout << "1 pagina" << endl;
else cout << N << " paginas" << endl;
}
return 0;
}
``````
Copy The Code &

Input

cmd
3 16 5
0

Output

cmd
120 paginas

### #3 Code Example with Java Programming

```Code - Java Programming```

``````
import java.io.IOException;
import java.io.PrintWriter;

public class Main {
static PrintWriter out = new PrintWriter(System.out);

public static void main(String[] args) throws IOException {
String l;
int Q, D, P, pag;
String[] parameters = l.split("\\s");
Q = Integer.parseInt(parameters);
D = Integer.parseInt(parameters);
P = Integer.parseInt(parameters);
pag = (int) (P * D * Q) / (P - Q);
String ouput = pag + " pagina";
ouput += (pag == 1) ? "" : "s";
out.println(ouput);
}
out.close();
}
}
``````
Copy The Code &

Input

cmd
3 16 5
0

Output

cmd
120 paginas

### #4 Code Example with Javascript Programming

```Code - Javascript Programming```

``````
const { createReadStream } = require("node:fs")
const { createInterface } = require("node:readline")

//// READING FILE | STREAMS ////
/**
* @param {import("node:fs").PathLike} path
* @param {BufferEncoding} encoding
*/
static createReadLineInterface(path, encoding = "utf8") {
encoding: encoding,
flags: "r",
emitClose: true,
autoClose: true
}

return createInterface({
crlfDelay: Infinity,
terminal: false
})
}

/**
* @param {import("node:fs").PathLike} path
* @param {BufferEncoding} encoding
*/
static create(path, encoding) {

let EOF = false

const nextLineGenerator = (async function* () {
for await (const line of RLI)
yield line
})()

RLI.once("close", () => { EOF = true })

return {
hasNextLine: () => !EOF,
nextLine: async (/** @type {unknown} */ fn) => {
const { value } = (await nextLineGenerator.next())
return (typeof fn === "function") ? fn(value) : value
},
close: () => RLI.close()
}
}
}

async function main() {
const PATH = "/dev/stdin"
const ENCODING = "utf8"

const output = []

const helper = (line = "") => line.split(" ", 3).map(value => Number.parseInt(value, 10))

const [Q, D = 0, P = 0] = await nextLine()

if (Q === 0) break
const bookPagesQuantity = Math.floor((Q * D * P) / (P - Q))

output.push(
bookPagesQuantity === 1 ?
`\${bookPagesQuantity} pagina` :
`\${bookPagesQuantity} paginas`
)
}

console.log(output.join("\n"))
}

main()

``````
Copy The Code &

Input

cmd
3 16 5
0

Output

cmd
120 paginas

### #5 Code Example with Python Programming

```Code - Python Programming```

``````
while True:
e = [int(x) for x in str(input()).split()]
if e == 0: break
q = e
d = e
p = e
n = int((q * d * p) / (p - q))
if n == 1: print('1 pagina')
else: print('{} paginas'.format(n))

``````
Copy The Code &

Input

cmd
3 16 5
0

Output

cmd
120 paginas